aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2014-11-28 16:49:48 +0000
committerLouise Crow <louise.crow@gmail.com>2014-12-15 18:04:22 +0000
commitbe43f90852304793642ea752c358aebaf6f7bef1 (patch)
tree64227ac5219941a12a6c12b662b095a270014f00 /spec/controllers
parent318946c869a7cbe6360118308eea8e97fb136f1b (diff)
Add basic update action.
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/admin_holidays_controller_spec.rb40
1 files changed, 38 insertions, 2 deletions
diff --git a/spec/controllers/admin_holidays_controller_spec.rb b/spec/controllers/admin_holidays_controller_spec.rb
index 61833b425..7025daa81 100644
--- a/spec/controllers/admin_holidays_controller_spec.rb
+++ b/spec/controllers/admin_holidays_controller_spec.rb
@@ -34,18 +34,54 @@ describe AdminHolidaysController do
before do
@holiday = FactoryGirl.create(:holiday)
+ get :edit, :id => @holiday.id
end
it 'renders the edit template' do
- get :edit, :id => @holiday.id
expect(response).to render_template('edit')
end
it 'gets the holiday in the id param' do
- get :edit, :id => @holiday.id
assigns[:holiday].should == @holiday
end
+ end
+
+ describe :update do
+
+ before do
+ @holiday = FactoryGirl.create(:holiday, :day => Date.new(2010, 1, 1),
+ :description => "Test Holiday")
+ put :update, :id => @holiday.id, :holiday => { :description => 'New Test Holiday' }
+ end
+
+ it 'gets the holiday in the id param' do
+ assigns[:holiday].should == @holiday
+ end
+
+ it 'updates the holiday' do
+ holiday = Holiday.find(@holiday.id).description.should == 'New Test Holiday'
+ end
+
+ it 'shows the admin a success message' do
+ flash[:notice].should == 'Holiday successfully updated.'
+ end
+
+ it 'redirects to the index' do
+ response.should redirect_to admin_holidays_path
+ end
+
+ context 'when there are errors' do
+
+ before do
+ Holiday.any_instance.stub(:update_attributes).and_return(false)
+ put :update, :id => @holiday.id, :holiday => { :description => 'New Test Holiday' }
+ end
+
+ it 'renders the edit template' do
+ expect(response).to render_template('edit')
+ end
+ end
end