summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrpereira2 <rpereira@gitlab.com>2019-02-05 17:45:43 +0530
committerrpereira2 <rpereira@gitlab.com>2019-02-07 10:37:07 +0530
commit40cfc102619b08bfb7708af3830feef244a6e137 (patch)
tree06db00db512c370a4754786aaf29153f0231b59d
parent12bb2f8bb46798da72dda5e2e176dba4076cb219 (diff)
downloadgitlab-ce-40cfc102619b08bfb7708af3830feef244a6e137.tar.gz
Use let in specs as is commonly used
-rw-r--r--spec/controllers/projects/settings/operations_controller_spec.rb6
-rw-r--r--spec/services/projects/operations/update_service_spec.rb30
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