OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add test case that no CustomStlye exists when trying to update
Henriette Dingere398a275aa67
diff --git a/spec/controllers/custom_styles_controller_spec.rb b/spec/controllers/custom_styles_controller_spec.rbindex a79bc4d2bd1..ad835a581c2 100644--- a/spec/controllers/custom_styles_controller_spec.rb+++ b/spec/controllers/custom_styles_controller_spec.rb@@ -115,29 +115,59 @@ describe CustomStylesController, type: :controller do}end- before do- with_enterprise_token(:define_custom_style)+ context 'with an existing CustomStyle' do+ before do+ with_enterprise_token(:define_custom_style)- expect(CustomStyle).to receive(:current).and_return(custom_style)- expect(custom_style).to receive(:update).and_return(valid)+ expect(CustomStyle).to receive(:current).and_return(custom_style)+ expect(custom_style).to receive(:update).and_return(valid)- post :update, params: params- end+ post :update, params: params+ end- context 'valid custom_style input' do- let(:valid) { true }+ context 'valid custom_style input' do+ let(:valid) { true }- it 'redirects to show' do- expect(response).to redirect_to action: :show+ it 'redirects to show' do+ expect(response).to redirect_to action: :show+ end+ end++ context 'invalid custom_style input' do+ let(:valid) { false }++ it 'renders with error' do+ expect(response).not_to be_redirect+ expect(response).to render_template 'custom_styles/show'+ endendend- context 'invalid custom_style input' do- let(:valid) { false }+ context 'without an existing CustomStyle' do+ before do+ with_enterprise_token(:define_custom_style)- it 'renders with error' do- expect(response).not_to be_redirect- expect(response).to render_template 'custom_styles/show'+ expect(CustomStyle).to receive(:create!).and_return(custom_style)+ expect(custom_style).to receive(:update).and_return(valid)++ post :update, params: params+ end++ context 'valid custom_style input' do+ let(:valid) { true }++ it 'redirects to show' do+ expect(response).to redirect_to action: :show+ end+ end++ context 'invalid custom_style input' do+ let(:valid) { false }++ it 'renders with error' do+ expect(response).not_to be_redirect+ expect(response).to render_template 'custom_styles/show'+ endendendend