diff options
-rw-r--r-- | spec/controllers/projects/settings/operations_controller_spec.rb | 6 | ||||
-rw-r--r-- | spec/services/projects/operations/update_service_spec.rb | 30 |
2 files changed, 18 insertions, 18 deletions
diff --git a/spec/controllers/projects/settings/operations_controller_spec.rb b/spec/controllers/projects/settings/operations_controller_spec.rb index 99568ddaa28..60b79597a00 100644 --- a/spec/controllers/projects/settings/operations_controller_spec.rb +++ b/spec/controllers/projects/settings/operations_controller_spec.rb @@ -91,6 +91,8 @@ describe Projects::Settings::OperationsController do end context 'format json' do + let(:body) { Gitlab::Utils.deep_indifferent_access(JSON.parse(response.body)) } + context 'when update succeeds' do before do stub_operations_update_service_returning(status: :success) @@ -99,8 +101,6 @@ describe Projects::Settings::OperationsController do it 'returns success status' do patch :update, params: project_params(project, error_tracking_params, format: :json) - body = Gitlab::Utils.deep_indifferent_access(JSON.parse(response.body)) - expect(body).to eq('status' => 'success', 'message' => 'Your changes have been saved') end end @@ -113,8 +113,6 @@ describe Projects::Settings::OperationsController do it 'returns error' do patch :update, params: project_params(project, error_tracking_params, format: :json) - body = Gitlab::Utils.deep_indifferent_access(JSON.parse(response.body)) - expect(response).to have_gitlab_http_status(:bad_request) expect(body[:message]).not_to be_nil end diff --git a/spec/services/projects/operations/update_service_spec.rb b/spec/services/projects/operations/update_service_spec.rb index fb80967a776..a26def4b258 100644 --- a/spec/services/projects/operations/update_service_spec.rb +++ b/spec/services/projects/operations/update_service_spec.rb @@ -44,20 +44,22 @@ describe Projects::Operations::UpdateService do expect(project.error_tracking_setting.read_attribute(:organization_name)).to eq('Org') end - it 'can set api_url to nil' do - params[:error_tracking_setting_attributes][:api_host] = '' - params[:error_tracking_setting_attributes][:enabled] = false - - result = subject.execute - - expect(result[:status]).to eq(:success) - - project.reload - expect(project.error_tracking_setting).not_to be_enabled - expect(project.error_tracking_setting.api_url).to be_nil - expect(project.error_tracking_setting.token).to eq('token') - expect(project.error_tracking_setting.read_attribute(:project_name)).to eq('Project') - expect(project.error_tracking_setting.read_attribute(:organization_name)).to eq('Org') + context 'disable error tracking' do + before do + params[:error_tracking_setting_attributes][:api_host] = '' + params[:error_tracking_setting_attributes][:enabled] = false + end + + it 'can set api_url to nil' do + expect(result[:status]).to eq(:success) + + project.reload + expect(project.error_tracking_setting).not_to be_enabled + expect(project.error_tracking_setting.api_url).to be_nil + expect(project.error_tracking_setting.token).to eq('token') + expect(project.error_tracking_setting.read_attribute(:project_name)).to eq('Project') + expect(project.error_tracking_setting.read_attribute(:organization_name)).to eq('Org') + end end end |