Class: FlashBaseHelpersTest
- Inherits:
-
ActionController::TestCase
- Object
- ActionController::TestCase
- FlashBaseHelpersTest
- Defined in:
- lib/vendor/plugins/inherited_resources/test/flash_test.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #test_failure_flash_message_on_create_with_namespaced_controller_actions ⇒ Object
- #test_failure_flash_message_on_update ⇒ Object
- #test_inherited_success_flash_message_on_update_on_namespaced_controllers ⇒ Object
- #test_success_flash_message_on_create_with_namespaced_controller ⇒ Object
- #test_success_flash_message_on_create_with_yml ⇒ Object
- #test_success_flash_message_on_destroy ⇒ Object
- #test_success_flash_message_on_update ⇒ Object
Instance Method Details
#setup ⇒ Object
27 28 29 30 31 32 |
# File 'lib/vendor/plugins/inherited_resources/test/flash_test.rb', line 27 def setup super @request.accept = 'application/xml' @controller.stubs(:resource_url).returns("http://test.host/") @controller.stubs(:collection_url).returns("http://test.host/") end |
#test_failure_flash_message_on_create_with_namespaced_controller_actions ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/vendor/plugins/inherited_resources/test/flash_test.rb', line 48 def @controller = Admin::AddressesController.new @controller.stubs(:resource_url).returns("http://test.host/") Address.stubs(:new).returns(mock_address(:save => false)) post :create assert_equal 'Admin error message.', flash[:error] end |
#test_failure_flash_message_on_update ⇒ Object
72 73 74 75 76 |
# File 'lib/vendor/plugins/inherited_resources/test/flash_test.rb', line 72 def Address.stubs(:find).returns(mock_address(:update_attributes => false, :errors => {:some => :error})) put :update assert_equal 'Oh no! We could not update your address!', flash[:error] end |
#test_inherited_success_flash_message_on_update_on_namespaced_controllers ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/vendor/plugins/inherited_resources/test/flash_test.rb', line 56 def @controller = Admin::AddressesController.new @controller.stubs(:resource_url).returns("http://test.host/") Address.stubs(:find).returns(mock_address(:update_attributes => true)) put :update assert_response :success assert_equal 'Nice! Address was updated with success!', flash[:notice] end |
#test_success_flash_message_on_create_with_namespaced_controller ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/vendor/plugins/inherited_resources/test/flash_test.rb', line 40 def @controller = Admin::AddressesController.new @controller.stubs(:resource_url).returns("http://test.host/") Address.stubs(:new).returns(mock_address(:save => true)) post :create assert_equal 'Admin, you created a new address close to <b>Ocean Avenue</b>.', flash[:notice] end |
#test_success_flash_message_on_create_with_yml ⇒ Object
34 35 36 37 38 |
# File 'lib/vendor/plugins/inherited_resources/test/flash_test.rb', line 34 def Address.stubs(:new).returns(mock_address(:save => true)) post :create assert_equal 'You created a new address close to <b>Ocean Avenue</b>.', flash[:notice] end |
#test_success_flash_message_on_destroy ⇒ Object
78 79 80 81 82 |
# File 'lib/vendor/plugins/inherited_resources/test/flash_test.rb', line 78 def Address.stubs(:find).returns(mock_address(:destroy => true)) delete :destroy assert_equal 'Address was successfully destroyed.', flash[:notice] end |
#test_success_flash_message_on_update ⇒ Object
65 66 67 68 69 70 |
# File 'lib/vendor/plugins/inherited_resources/test/flash_test.rb', line 65 def Address.stubs(:find).returns(mock_address(:update_attributes => true)) put :update assert_response :success assert_equal 'Nice! Address was updated with success!', flash[:notice] end |