DEV: Add test for assigned

DEV: Add test for assigned

Follow-up to c46764e804eba339e10015e824402887bad38781

diff --git a/spec/requests/assign_controller_spec.rb b/spec/requests/assign_controller_spec.rb
index 9a69cc0..ddbc4fe 100644
--- a/spec/requests/assign_controller_spec.rb
+++ b/spec/requests/assign_controller_spec.rb
@@ -152,4 +152,35 @@ RSpec.describe DiscourseAssign::AssignController do
     end
   end
 
+  context '#assigned' do
+    include_context 'A group that is allowed to assign'
+
+    fab!(:post1) { Fabricate(:post) }
+    fab!(:post2) { Fabricate(:post) }
+    fab!(:post3) { Fabricate(:post) }
+
+    before do
+      add_to_assign_allowed_group(user2)
+
+      TopicAssigner.new(post1.topic, user).assign(user)
+      TopicAssigner.new(post2.topic, user2).assign(user2)
+      TopicAssigner.new(post3.topic, user).assign(user)
+
+      sign_in(user)
+    end
+
+    it 'lists topics ordered by user' do
+      get '/assign/assigned.json'
+      expect(JSON.parse(response.body)['topics'].map { |t| t['id'] }).to match_array([post2.topic_id, post1.topic_id, post3.topic_id])
+    end
+
+    it 'works with offset and limit' do
+      get '/assign/assigned.json', params: { limit: 2 }
+      expect(JSON.parse(response.body)['topics'].map { |t| t['id'] }).to match_array([post2.topic_id, post1.topic_id])
+
+      get '/assign/assigned.json', params: { offset: 2 }
+      expect(JSON.parse(response.body)['topics'].map { |t| t['id'] }).to match_array([post3.topic_id])
+    end
+  end
+
 end

GitHub sha: eb2359dc

1 Like