diff --git a/spec/controllers/admin/booths_controller_spec.rb b/spec/controllers/admin/booths_controller_spec.rb index 1cfc1b02..f31bd5a6 100644 --- a/spec/controllers/admin/booths_controller_spec.rb +++ b/spec/controllers/admin/booths_controller_spec.rb @@ -54,7 +54,7 @@ describe Admin::BoothsController do end describe 'POST #create' do - # context 'successfully created' do + context 'successfully created' do # it 'creates a new booth' do # expected = expect do # post :create, booth: attributes_for(:booth), conference_id: conference.short_title @@ -62,16 +62,21 @@ describe Admin::BoothsController do # expected.to change { Booth.count }.by(1) # end # - # it 'redirects to admin booth index' do - # post :create, booth: attributes_for(:booth), conference_id: conference.short_title - # expect(response).to redirect_to(admin_conference_booths_path) - # end + # it 'redirects to admin booth index' do + # post :create, booth: attributes_for(:booth), conference_id: conference.short_title + # expect(response).to redirect_to(admin_conference_booths_path) + # end # - # it 'shows success message' do - # post :create, booth: attributes_for(:booth), conference_id: conference.short_title - # expect(flash[:notice]).to match('Booth successfully created.') - # end - # end + # it 'has responsibles' do + # post :create, booth: attributes_for(:booth), conference_id: conference.short_title + # expect(booth.responsibles.count).to eq(0) + # end + + it 'shows success message' do + post :create, booth: attributes_for(:booth), conference_id: conference.short_title + expect(flash[:error]).to match('Booth successfully created.') + end + end context 'create action fails' do it 'does not create any record' do @@ -119,7 +124,7 @@ describe Admin::BoothsController do context 'deletes successfully' do # it 'booth deleted' do # expected = expect do - # delete :destroy, id: booth.iddelete :destroy, id: booth.id, conference_id: conference.short_title + # delete :destroy, id: booth.id, conference_id: conference.short_title # end # expected.to change { Booth.count }.by(-1) # end diff --git a/spec/factories/booth_request.rb b/spec/factories/booth_request.rb new file mode 100644 index 00000000..fba0cace --- /dev/null +++ b/spec/factories/booth_request.rb @@ -0,0 +1,8 @@ +FactoryGirl.define do + factory :booth_request do + booth + user + role 'responsible' + + end +end diff --git a/spec/factories/booths.rb b/spec/factories/booths.rb index a67d30f0..7b096bcb 100644 --- a/spec/factories/booths.rb +++ b/spec/factories/booths.rb @@ -9,7 +9,8 @@ FactoryGirl.define do conference after(:build) do |booth| - booth.responsibles << create(:user) + booth.responsibles << create(:booth_request).user end + end end