Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-21 03:09:18 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-21 03:09:18 +0300
commit1ccf61bdccd3f0cbcabd7fe335542014f465f46b (patch)
treef6eb90ccf27bb2193251d1617e7b655429eb2ac6 /spec
parent68f1860e6f1f9e8441c434f4e62238c359ce8c7c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/projects/issues_controller_spec.rb55
-rw-r--r--spec/fixtures/api/schemas/entities/user.json3
-rw-r--r--spec/support/shared_examples/requests/api/discussions_shared_examples.rb56
3 files changed, 56 insertions, 58 deletions
diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb
index 806a4e2f52c..add7778b57a 100644
--- a/spec/controllers/projects/issues_controller_spec.rb
+++ b/spec/controllers/projects/issues_controller_spec.rb
@@ -1390,6 +1390,61 @@ describe Projects::IssuesController do
expect(note_json['author']['status_tooltip_html']).to be_present
end
+ context 'is_gitlab_employee attribute' do
+ subject { get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issue.iid } }
+
+ before do
+ allow(Gitlab).to receive(:com?).and_return(true)
+ note_user = discussion.author
+ note_user.update(email: email)
+ note_user.confirm
+ end
+
+ shared_examples 'non inclusion of gitlab employee badge' do
+ it 'does not render the is_gitlab_employee attribute' do
+ subject
+
+ note_json = json_response.first['notes'].first
+
+ expect(note_json['author']['is_gitlab_employee']).to be nil
+ end
+ end
+
+ context 'when user is a gitlab employee' do
+ let(:email) { 'test@gitlab.com' }
+
+ it 'renders the is_gitlab_employee attribute' do
+ subject
+
+ note_json = json_response.first['notes'].first
+
+ expect(note_json['author']['is_gitlab_employee']).to be true
+ end
+
+ context 'when feature flag is disabled' do
+ before do
+ stub_feature_flags(gitlab_employee_badge: false)
+ end
+
+ it_behaves_like 'non inclusion of gitlab employee badge'
+ end
+ end
+
+ context 'when user is not a gitlab employee' do
+ let(:email) { 'test@example.com' }
+
+ it_behaves_like 'non inclusion of gitlab employee badge'
+
+ context 'when feature flag is disabled' do
+ before do
+ stub_feature_flags(gitlab_employee_badge: false)
+ end
+
+ it_behaves_like 'non inclusion of gitlab employee badge'
+ end
+ end
+ end
+
it 'does not cause an extra query for the status' do
control = ActiveRecord::QueryRecorder.new do
get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issue.iid }
diff --git a/spec/fixtures/api/schemas/entities/user.json b/spec/fixtures/api/schemas/entities/user.json
index 1e0c8885609..82d80b75cef 100644
--- a/spec/fixtures/api/schemas/entities/user.json
+++ b/spec/fixtures/api/schemas/entities/user.json
@@ -17,8 +17,7 @@
"path": { "type": "string" },
"name": { "type": "string" },
"username": { "type": "string" },
- "status_tooltip_html": { "$ref": "../types/nullable_string.json" },
- "is_gitlab_employee": { "type": "boolean" }
+ "status_tooltip_html": { "$ref": "../types/nullable_string.json" }
},
"additionalProperties": false
}
diff --git a/spec/support/shared_examples/requests/api/discussions_shared_examples.rb b/spec/support/shared_examples/requests/api/discussions_shared_examples.rb
index 3ad2263688b..939ea405724 100644
--- a/spec/support/shared_examples/requests/api/discussions_shared_examples.rb
+++ b/spec/support/shared_examples/requests/api/discussions_shared_examples.rb
@@ -55,58 +55,6 @@ RSpec.shared_examples 'with cross-reference system notes' do
end
RSpec.shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_reply_to_individual_notes: false|
- shared_examples 'is_gitlab_employee attribute presence' do
- subject { get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user) }
-
- before do
- allow(Gitlab).to receive(:com?).and_return(true)
- user.update(email: email)
- user.confirm
- end
-
- context 'when author is a gitlab employee' do
- let(:email) { 'test@gitlab.com' }
-
- it 'returns is_gitlab_employee as true' do
- subject
-
- expect(json_response.first["notes"].first["author"]['is_gitlab_employee']).to be true
- end
- end
-
- shared_examples 'non inclusion of gitlab employee badge' do
- it 'does not include is_gitlab_employee attribute' do
- subject
-
- expect(json_response.first["notes"].first["author"]).not_to have_key('is_gitlab_employee')
- end
- end
-
- context 'when author is not a gitlab employee' do
- let(:email) { 'test@example.com' }
-
- it_behaves_like 'non inclusion of gitlab employee badge'
- end
-
- describe 'when feature flag is disabled' do
- before do
- stub_feature_flags(gitlab_employee_badge: false)
- end
-
- context 'when author is a gitlab employee' do
- let(:email) { 'test@gitlab.com' }
-
- it_behaves_like 'non inclusion of gitlab employee badge'
- end
-
- context 'when author is not a gitlab employee' do
- let(:email) { 'test@example.com' }
-
- it_behaves_like 'non inclusion of gitlab employee badge'
- end
- end
- end
-
describe "GET /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions" do
it "returns an array of discussions" do
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user)
@@ -130,8 +78,6 @@ RSpec.shared_examples 'discussions API' do |parent_type, noteable_type, id_name,
expect(response).to have_gitlab_http_status(:not_found)
end
-
- it_behaves_like 'is_gitlab_employee attribute presence'
end
describe "GET /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions/:discussion_id" do
@@ -250,8 +196,6 @@ RSpec.shared_examples 'discussions API' do |parent_type, noteable_type, id_name,
end
end
end
-
- it_behaves_like 'is_gitlab_employee attribute presence'
end
describe "POST /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions/:discussion_id/notes" do