aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/admin_holiday_imports_controller_spec.rb73
-rw-r--r--spec/controllers/admin_holidays_controller_spec.rb3
2 files changed, 75 insertions, 1 deletions
diff --git a/spec/controllers/admin_holiday_imports_controller_spec.rb b/spec/controllers/admin_holiday_imports_controller_spec.rb
new file mode 100644
index 000000000..dd23a022f
--- /dev/null
+++ b/spec/controllers/admin_holiday_imports_controller_spec.rb
@@ -0,0 +1,73 @@
+require 'spec_helper'
+
+describe AdminHolidayImportsController do
+
+ describe :new do
+
+ it 'renders the new template' do
+ get :new
+ expect(response).to render_template('new')
+ end
+
+ it 'creates an import' do
+ get :new
+ assigns[:holiday_import].should be_instance_of(HolidayImport)
+ end
+
+ describe 'if the import is valid' do
+
+ it 'populates the import' do
+ mock_import = mock(HolidayImport, :valid? => true,
+ :populate => nil)
+ HolidayImport.stub!(:new).and_return(mock_import)
+ mock_import.should_receive(:populate)
+ get :new
+ end
+
+ end
+
+ end
+
+ describe :create do
+
+ it 'creates an import' do
+ post :create
+ assigns[:holiday_import].should be_instance_of(HolidayImport)
+ end
+
+ describe 'if the import can be saved' do
+
+ before do
+ mock_import = mock(HolidayImport, :save => true)
+ HolidayImport.stub!(:new).and_return(mock_import)
+ post :create
+ end
+
+ it 'should show a success notice' do
+ flash[:notice].should == 'Holidays successfully imported'
+ end
+
+ it 'should redirect to the index' do
+ response.should redirect_to(admin_holidays_path)
+ end
+
+ end
+
+ describe 'if the import cannot be saved' do
+
+ before do
+ mock_import = mock(HolidayImport, :save => false)
+ HolidayImport.stub!(:new).and_return(mock_import)
+ post :create
+ end
+
+ it 'should render the new template' do
+ expect(response).to render_template('new')
+ end
+
+ end
+
+ end
+
+
+end
diff --git a/spec/controllers/admin_holidays_controller_spec.rb b/spec/controllers/admin_holidays_controller_spec.rb
index 1f76a7fcb..21cb51d29 100644
--- a/spec/controllers/admin_holidays_controller_spec.rb
+++ b/spec/controllers/admin_holidays_controller_spec.rb
@@ -51,7 +51,8 @@ describe AdminHolidaysController do
end
it 'creates a new holiday' do
- assigns[:holiday].should be_an_instance_of(Holiday)
+ get :new
+ assigns[:holiday].should be_instance_of(Holiday)
end
end