Class: SingletonTest

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

Instance Method Summary collapse

Instance Method Details

#setupObject



20
21
22
23
# File 'lib/vendor/plugins/inherited_resources/test/singleton_test.rb', line 20

def setup
  @controller.stubs(:resource_url).returns('/')
  @controller.stubs(:collection_url).returns('/')
end

#test_expose_a_new_manager_on_newObject



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

def test_expose_a_new_manager_on_new
  Store.expects(:find).with('37').returns(mock_store)
  mock_store.expects(:build_manager).returns(mock_manager)
  get :new, :store_id => '37'
  assert_equal mock_store, assigns(:store)
  assert_equal mock_manager, assigns(:manager)
end

#test_expose_a_newly_create_manager_on_createObject



50
51
52
53
54
55
56
# File 'lib/vendor/plugins/inherited_resources/test/singleton_test.rb', line 50

def test_expose_a_newly_create_manager_on_create
  Store.expects(:find).with('37').returns(mock_store)
  mock_store.expects(:build_manager).with({'these' => 'params'}).returns(mock_manager(:save => true))
  post :create, :store_id => '37', :manager => {:these => 'params'}
  assert_equal mock_store, assigns(:store)
  assert_equal mock_manager, assigns(:manager)
end

#test_expose_the_resquested_manager_on_editObject



41
42
43
44
45
46
47
48
# File 'lib/vendor/plugins/inherited_resources/test/singleton_test.rb', line 41

def test_expose_the_resquested_manager_on_edit
  Store.expects(:find).with('37').returns(mock_store)
  mock_store.expects(:manager).returns(mock_manager)
  get :edit, :store_id => '37'
  assert_equal mock_store, assigns(:store)
  assert_equal mock_manager, assigns(:manager)
  assert_response :success
end

#test_expose_the_resquested_manager_on_showObject



25
26
27
28
29
30
31
# File 'lib/vendor/plugins/inherited_resources/test/singleton_test.rb', line 25

def test_expose_the_resquested_manager_on_show
  Store.expects(:find).with('37').returns(mock_store)
  mock_store.expects(:manager).returns(mock_manager)
  get :show, :store_id => '37'
  assert_equal mock_store, assigns(:store)
  assert_equal mock_manager, assigns(:manager)
end

#test_the_resquested_manager_is_destroyed_on_destroyObject



66
67
68
69
70
71
72
73
# File 'lib/vendor/plugins/inherited_resources/test/singleton_test.rb', line 66

def test_the_resquested_manager_is_destroyed_on_destroy
  Store.expects(:find).with('37').returns(mock_store)
  mock_store.expects(:manager).returns(mock_manager)
  mock_manager.expects(:destroy)
  delete :destroy, :store_id => '37'
  assert_equal mock_store, assigns(:store)
  assert_equal mock_manager, assigns(:manager)
end

#test_update_the_requested_object_on_updateObject



58
59
60
61
62
63
64
# File 'lib/vendor/plugins/inherited_resources/test/singleton_test.rb', line 58

def test_update_the_requested_object_on_update
  Store.expects(:find).with('37').returns(mock_store(:manager => mock_manager))
  mock_manager.expects(:update_attributes).with({'these' => 'params'}).returns(true)
  put :update, :store_id => '37', :manager => {:these => 'params'}
  assert_equal mock_store, assigns(:store)
  assert_equal mock_manager, assigns(:manager)
end