diff options
author | Louise Crow <louise.crow@gmail.com> | 2014-12-15 17:16:11 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2014-12-15 18:23:05 +0000 |
commit | 8e69a9372fb29bc8107ee8c542f9408efa54b76e (patch) | |
tree | 763662478955bb44584b6abd9a060c6aa7863f53 /spec/controllers | |
parent | ceae995a5356a651f5e466afc2cd30ff70fe1555 (diff) |
Allow import of holidays from feed or built-in suggestions
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/admin_holiday_imports_controller_spec.rb | 73 | ||||
-rw-r--r-- | spec/controllers/admin_holidays_controller_spec.rb | 3 |
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 |