Merge pull request #41 from SuperTux88/ruby-2.1-rails-4.2

Activate ruby 2.1 with rails 4.2 on travis again
This commit is contained in:
Benjamin Neff 2016-11-08 02:35:54 +01:00 committed by GitHub
commit 4671ed9fd4
9 changed files with 77 additions and 5 deletions

View file

@ -183,3 +183,7 @@ Style/NumericPredicate:
Style/FrozenStringLiteralComment:
Enabled: false
Rails/HttpPositionalArguments:
Exclude:
- "spec/controllers/diaspora_federation/fixtures_rails4_spec.rb"

View file

@ -3,6 +3,7 @@ language: ruby
rvm:
- 2.3.1
- 2.2.5
- 2.1
sudo: false
cache:
@ -13,7 +14,7 @@ branches:
- 'master'
- 'develop'
before_install: gem install bundler
before_install: test/scripts/prepare-travis.sh
bundler_args: "--deployment --without development --jobs=3 --retry=3"
script: bundle exec rake --trace
script: test/scripts/travis.sh

15
lib/tasks/rails4.rake Normal file
View file

@ -0,0 +1,15 @@
if defined?(RSpec)
namespace :rails4 do
desc "Run all specs that generate fixtures for rspec with rails 4"
RSpec::Core::RakeTask.new(:generate_fixtures) do |t|
t.rspec_opts = ["--tag fixture4"]
end
desc "Run all specs in spec directory (exluding controller specs)"
RSpec::Core::RakeTask.new(:spec) do |task|
task.pattern = FileList["spec/**/*_spec.rb"].exclude("spec/controllers/**/*_spec.rb")
end
task test: %w(spec:prepare_db generate_fixtures spec)
end
end

View file

@ -0,0 +1,21 @@
module DiasporaFederation
describe WebfingerController, type: :controller do
routes { DiasporaFederation::Engine.routes }
it "generates webfinger fixture", fixture4: true, rails4: true do
get :legacy_webfinger, q: "alice@localhost:3000"
expect(response).to be_success
save_fixture(response.body, "legacy-webfinger")
end
end
describe HCardController, type: :controller do
routes { DiasporaFederation::Engine.routes }
it "generates hcard fixture", fixture4: true, rails4: true do
get :hcard, guid: alice.guid
expect(response).to be_success
save_fixture(response.body, "hcard")
end
end
end

View file

@ -8,7 +8,7 @@ module DiasporaFederation
WebfingerController.instance_variable_set(:@host_meta_xml, nil) # clear cache
end
it "succeeds", fixture: true do
it "succeeds", fixture: true, fixture4: true do
get :host_meta
expect(response).to be_success
save_fixture(response.body, "host-meta")

View file

@ -66,6 +66,8 @@ RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/test/fixtures"
config.global_fixtures = :all
config.filter_run_excluding rails4: true if Rails::VERSION::MAJOR == 5
# whitelist codeclimate.com so test coverage can be reported
config.after(:suite) do
WebMock.disable_net_connect!(allow: "codeclimate.com")

View file

@ -13,8 +13,13 @@ Rails.application.configure do
config.eager_load = false
# Configure static file server for tests with Cache-Control for performance.
if Rails::VERSION::MAJOR == 5
config.public_file_server.enable = true
config.public_file_server.headers = {"Cache-Control" => "public, max-age=3600"}
else
config.serve_static_files = true
config.static_cache_control = "public, max-age=3600"
end
# Show full error reports and disable caching.
config.consider_all_requests_local = true

12
test/scripts/prepare-travis.sh Executable file
View file

@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -x
gem install bundler
if [[ ${TRAVIS_RUBY_VERSION} == "2.1" ]]; then
# use rails 4 for ruby 2.1, because rails 5 needs ruby >= 2.2.2
echo "gem 'rails', '4.2.7.1'" >> Gemfile
bundle install --without development --jobs=3 --retry=3
bundle update rails
fi

12
test/scripts/travis.sh Executable file
View file

@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -x
if [[ ${TRAVIS_RUBY_VERSION} == "2.1" ]]; then
# ruby 2.1
export NO_COVERAGE="true" # No coverage for rails 4, because controller specs are disabled
bundle exec rake rails4:test --trace
else
# ruby >= 2.2
bundle exec rake --trace
fi