Skip to content

Commit

Permalink
Merge pull request heartcombo#3473 from georgemillo/test-yield
Browse files Browse the repository at this point in the history
adding test for RegistrationsController#new yielding the resource
  • Loading branch information
josevalim committed Feb 14, 2015
2 parents 2992b41 + a6a1524 commit 737ae36
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/controllers/custom_registrations_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ class CustomRegistrationsControllerTest < ActionController::TestCase
put :update, { user: { } }
assert @controller.update_block_called?, "update failed to yield resource to provided block"
end

test "yield resource to block on new" do
get :new
assert @controller.new_block_called?, "new failed to yield resource to provided block"
end
end
10 changes: 10 additions & 0 deletions test/rails_app/app/controllers/custom/registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
class Custom::RegistrationsController < Devise::RegistrationsController
def new
super do |resource|
@new_block_called = true
end
end

def create
super do |resource|
@create_block_called = true
Expand All @@ -18,4 +24,8 @@ def create_block_called?
def update_block_called?
@update_block_called == true
end

def new_block_called?
@new_block_called == true
end
end

0 comments on commit 737ae36

Please sign in to comment.