Skip to content

Commit

Permalink
Patch ActionController::TestCase#assigns for Rails5
Browse files Browse the repository at this point in the history
  • Loading branch information
bf4 committed Nov 24, 2015
1 parent fed4621 commit e568c8f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ if version == 'master'
# Rails 5
gem 'actionview'
end
# Rails 5
gem 'rails-controller-testing', github: 'rails/rails-controller-testing'
else
gem_version = "~> #{version}.0"
gem 'railties', gem_version
Expand Down
8 changes: 8 additions & 0 deletions test/support/test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@
def setup
@routes = TestHelper::Routes
end

# For Rails5
# https://github.com/rails/rails/commit/ca83436d1b3b6cedd1eca2259f65661e69b01909#diff-b9bbf56e85d3fe1999f16317f2751e76L17
def assigns(key = nil)
assigns = {}.with_indifferent_access
@controller.view_assigns.each { |k, v| assigns.regular_writer(k, v) }
key.nil? ? assigns : assigns[key]
end
end

0 comments on commit e568c8f

Please sign in to comment.