2015-10-11 17:41:23 +08:00
|
|
|
require 'rails_helper'
|
2013-09-13 05:46:43 +08:00
|
|
|
|
|
|
|
describe ComposerMessagesController do
|
|
|
|
|
|
|
|
context '.index' do
|
|
|
|
|
|
|
|
it 'requires you to be logged in' do
|
2018-01-12 11:15:10 +08:00
|
|
|
get :index, format: :json
|
|
|
|
expect(response.status).to eq(403)
|
2013-09-13 05:46:43 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when logged in' do
|
|
|
|
let!(:user) { log_in }
|
2017-07-28 09:20:09 +08:00
|
|
|
let(:args) { { 'topic_id' => '123', 'post_id' => '333', 'composer_action' => 'reply' } }
|
2013-09-13 05:46:43 +08:00
|
|
|
|
|
|
|
it 'redirects to your user preferences' do
|
2017-08-31 12:06:56 +08:00
|
|
|
get :index, format: :json
|
2015-01-10 01:04:02 +08:00
|
|
|
expect(response).to be_success
|
2013-09-13 05:46:43 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'delegates args to the finder' do
|
|
|
|
finder = mock
|
|
|
|
ComposerMessagesFinder.expects(:new).with(instance_of(User), has_entries(args)).returns(finder)
|
|
|
|
finder.expects(:find)
|
2017-08-31 12:06:56 +08:00
|
|
|
get :index, params: args, format: :json
|
2013-09-13 05:46:43 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|