2015-10-11 05:41:23 -04:00
|
|
|
require 'rails_helper'
|
2013-09-12 17:46:43 -04:00
|
|
|
|
|
|
|
describe ComposerMessagesController do
|
|
|
|
|
|
|
|
context '.index' do
|
|
|
|
|
|
|
|
it 'requires you to be logged in' do
|
2015-01-09 12:04:02 -05:00
|
|
|
expect { xhr :get, :index }.to raise_error(Discourse::NotLoggedIn)
|
2013-09-12 17:46:43 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when logged in' do
|
|
|
|
let!(:user) { log_in }
|
2016-06-06 16:58:35 -04:00
|
|
|
let(:args) { {'topic_id' => '123', 'post_id' => '333', 'composer_action' => 'reply'} }
|
2013-09-12 17:46:43 -04:00
|
|
|
|
|
|
|
it 'redirects to your user preferences' do
|
|
|
|
xhr :get, :index
|
2015-01-09 12:04:02 -05:00
|
|
|
expect(response).to be_success
|
2013-09-12 17:46:43 -04: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)
|
|
|
|
xhr :get, :index, args
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|