Class: FlashBaseHelpersTest

Inherits:
ActionController::TestCase
  • Object
show all
Defined in:
lib/vendor/plugins/inherited_resources/test/flash_test.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



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_actionsObject



48
49
50
51
52
53
54
# File 'lib/vendor/plugins/inherited_resources/test/flash_test.rb', line 48

def test_failure_flash_message_on_create_with_namespaced_controller_actions
  @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_updateObject



72
73
74
75
76
# File 'lib/vendor/plugins/inherited_resources/test/flash_test.rb', line 72

def test_failure_flash_message_on_update
  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_controllersObject



56
57
58
59
60
61
62
63
# File 'lib/vendor/plugins/inherited_resources/test/flash_test.rb', line 56

def test_inherited_success_flash_message_on_update_on_namespaced_controllers
  @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_controllerObject



40
41
42
43
44
45
46
# File 'lib/vendor/plugins/inherited_resources/test/flash_test.rb', line 40

def test_success_flash_message_on_create_with_namespaced_controller
  @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_ymlObject



34
35
36
37
38
# File 'lib/vendor/plugins/inherited_resources/test/flash_test.rb', line 34

def test_success_flash_message_on_create_with_yml
  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_destroyObject



78
79
80
81
82
# File 'lib/vendor/plugins/inherited_resources/test/flash_test.rb', line 78

def test_success_flash_message_on_destroy
  Address.stubs(:find).returns(mock_address(:destroy => true))
  delete :destroy
  assert_equal 'Address was successfully destroyed.', flash[:notice]
end

#test_success_flash_message_on_updateObject



65
66
67
68
69
70
# File 'lib/vendor/plugins/inherited_resources/test/flash_test.rb', line 65

def test_success_flash_message_on_update
  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