parent
d59e7fe1fb
commit
eb2359dca1
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue