Skip to content

Commit

Permalink
Begin fixing compatibility with Rails 4 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Jul 29, 2016
1 parent dd5163b commit 0cde78c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
8 changes: 5 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

Internal::Application.config.active_job.queue_adapter = :inline

require 'rails-controller-testing' if Rails::VERSION::MAJOR >= 5
require 'rspec/collection_matchers'
require 'rspec/its'
require 'rspec/rails'
require 'rspec/active_model/mocks'
require 'rails-controller-testing'

require 'capybara/poltergeist'

Expand Down Expand Up @@ -91,8 +91,10 @@
config.after(:each, type: :feature) { Warden.test_reset! }
config.include Controllers::EngineHelpers, type: :controller
config.include Capybara::DSL
config.include ::Rails.application.routes.url_helpers
config.include ::Rails.application.routes.mounted_helpers
if Rails::VERSION::MAJOR >= 5
config.include ::Rails.application.routes.url_helpers
config.include ::Rails.application.routes.mounted_helpers
end
config.include Spotlight::TestFeaturesHelpers, type: :feature
end

Expand Down
6 changes: 6 additions & 0 deletions spec/support/helpers/controller_level_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ def blacklight_configuration_context

def initialize_controller_helpers(helper)
helper.extend ControllerLevelHelpers
initialize_routing_helpers(helper)
end

def initialize_routing_helpers(helper)
return unless Rails::VERSION::MAJOR >= 5

helper.class.include ::Rails.application.routes.url_helpers

if ::Rails.application.routes.respond_to?(:mounted_helpers)
Expand Down
1 change: 1 addition & 0 deletions spec/support/views/test_view_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module TestViewHelpers

included do
before do
view.send(:extend, Spotlight::MainAppHelpers)
view.send(:extend, Spotlight::CrudLinkHelpers)
view.send(:extend, Spotlight::TitleHelper)
view.send(:extend, Spotlight::NavbarHelper)
Expand Down
2 changes: 1 addition & 1 deletion spec/test_app_templates/Gemfile.extra
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
gem 'acts-as-taggable-on', github: 'mbleigh/acts-as-taggable-on'
gem 'rails-controller-testing'
gem 'rails-controller-testing', require: false
gem 'friendly_id', github: 'norman/friendly_id'
gem 'social-share-button', github: 'cbeer/social-share-button', branch: 'on_load'

0 comments on commit 0cde78c

Please sign in to comment.