summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-08-06 16:10:38 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-08-06 16:10:38 +0000
commitc5eb2977d7750a6f3255941f72a1002259468834 (patch)
tree0363458fc082e664f3bb7c5f7b6ed74290c772cc /spec
parent2c46cf084bcb0f06121f2fc4374379cc6f45ea0d (diff)
parent70f5291808469a808eb2bee70e9e97acc7716bb6 (diff)
downloadgitlab-ce-c5eb2977d7750a6f3255941f72a1002259468834.tar.gz
Merge branch 'add-current-user-to-autocomplete' into 'master'
Always add current user to autocomplete controller to support filter by "Me" ### What does this MR do? This MR always adds the current user to the autocomplete list of users. ### Why was this MR needed? Normally only the members from a team or the group are shown in the autocomplete list. However, this prevents a user from filtering issues belong to him/her if the user does not belong directly to either. To make this filtering more usable, we can be sure to add the current user to the list, which the JavaScript code will move to the top of the list. ### What are the relevant issue numbers? Partial fix #2202 See merge request !1100
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/autocomplete_controller_spec.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/controllers/autocomplete_controller_spec.rb b/spec/controllers/autocomplete_controller_spec.rb
index 1230017c270..3521d690259 100644
--- a/spec/controllers/autocomplete_controller_spec.rb
+++ b/spec/controllers/autocomplete_controller_spec.rb
@@ -4,6 +4,7 @@ describe AutocompleteController do
let!(:project) { create(:project) }
let!(:user) { create(:user) }
let!(:user2) { create(:user) }
+ let!(:non_member) { create(:user) }
context 'project members' do
before do
@@ -61,6 +62,27 @@ describe AutocompleteController do
end
end
+ context 'non-member login for public project' do
+ let!(:project) { create(:project, :public) }
+
+ before do
+ sign_in(non_member)
+ project.team << [user, :master]
+ end
+
+ let(:body) { JSON.parse(response.body) }
+
+ describe 'GET #users with project ID' do
+ before do
+ get(:users, project_id: project.id)
+ end
+
+ it { expect(body).to be_kind_of(Array) }
+ it { expect(body.size).to eq 2 }
+ it { expect(body.map { |u| u['username'] }).to match_array([user.username, non_member.username]) }
+ end
+ end
+
context 'all users' do
before do
sign_in(user)