aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/admin_holidays_controller.rb7
-rw-r--r--spec/controllers/admin_holidays_controller_spec.rb25
2 files changed, 32 insertions, 0 deletions
diff --git a/app/controllers/admin_holidays_controller.rb b/app/controllers/admin_holidays_controller.rb
index 3d7e0046b..51edfcaac 100644
--- a/app/controllers/admin_holidays_controller.rb
+++ b/app/controllers/admin_holidays_controller.rb
@@ -19,6 +19,13 @@ class AdminHolidaysController < AdminController
end
end
+ def destroy
+ @holiday = Holiday.find(params[:id])
+ @holiday.destroy
+ notice = "Holiday successfully destroyed"
+ redirect_to admin_holidays_path, :notice => notice
+ end
+
private
def get_all_holidays
diff --git a/spec/controllers/admin_holidays_controller_spec.rb b/spec/controllers/admin_holidays_controller_spec.rb
index 7025daa81..087a77b32 100644
--- a/spec/controllers/admin_holidays_controller_spec.rb
+++ b/spec/controllers/admin_holidays_controller_spec.rb
@@ -85,4 +85,29 @@ describe AdminHolidaysController do
end
+ describe :destroy do
+
+ before(:each) do
+ @holiday = FactoryGirl.create(:holiday)
+ delete :destroy, :id => @holiday.id
+ end
+
+ it 'finds the holiday to destroy' do
+ assigns(:holiday).should == @holiday
+ end
+
+ it 'destroys the holiday' do
+ assigns(:holiday).should be_destroyed
+ end
+
+ it 'tells the admin the holiday has been destroyed' do
+ msg = "Holiday successfully destroyed"
+ flash[:notice].should == msg
+ end
+
+ it 'redirects to the index action' do
+ expect(response).to redirect_to(admin_holidays_path)
+ end
+ end
+
end