summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorHiroyuki Sato <sathiroyuki@gmail.com>2017-08-30 07:48:55 +0000
committerPhil Hughes <me@iamphill.com>2017-08-30 07:48:55 +0000
commit7187395ef13d8d84a145d1b5251882ebada3f7f2 (patch)
tree06188448a7059648d5ca99c159f525eaf3499cc3 /spec/controllers
parentdf8ca5aaab21f47c328cc15f2c454b9cc97a3ed5 (diff)
downloadgitlab-ce-7187395ef13d8d84a145d1b5251882ebada3f7f2.tar.gz
Add filter by my reaction
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/autocomplete_controller_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/controllers/autocomplete_controller_spec.rb b/spec/controllers/autocomplete_controller_spec.rb
index 2fbab1e4040..572b567cddf 100644
--- a/spec/controllers/autocomplete_controller_spec.rb
+++ b/spec/controllers/autocomplete_controller_spec.rb
@@ -339,4 +339,42 @@ describe AutocompleteController do
end
end
end
+
+ context 'GET award_emojis' do
+ let(:user2) { create(:user) }
+ let!(:award_emoji1) { create_list(:award_emoji, 2, user: user, name: 'thumbsup') }
+ let!(:award_emoji2) { create_list(:award_emoji, 1, user: user, name: 'thumbsdown') }
+ let!(:award_emoji3) { create_list(:award_emoji, 3, user: user, name: 'star') }
+ let!(:award_emoji4) { create_list(:award_emoji, 1, user: user, name: 'tea') }
+
+ context 'unauthorized user' do
+ it 'returns empty json' do
+ get :award_emojis
+
+ expect(json_response).to be_empty
+ end
+ end
+
+ context 'sign in as user without award emoji' do
+ it 'returns empty json' do
+ sign_in(user2)
+ get :award_emojis
+
+ expect(json_response).to be_empty
+ end
+ end
+
+ context 'sign in as user with award emoji' do
+ it 'returns json sorted by name count' do
+ sign_in(user)
+ get :award_emojis
+
+ expect(json_response.count).to eq 4
+ expect(json_response[0]).to match('name' => 'star')
+ expect(json_response[1]).to match('name' => 'thumbsup')
+ expect(json_response[2]).to match('name' => 'tea')
+ expect(json_response[3]).to match('name' => 'thumbsdown')
+ end
+ end
+ end
end