2013-05-26 20:22:37 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe UserActionsController do
|
|
|
|
context 'index' do
|
|
|
|
|
2013-05-26 21:02:58 -04:00
|
|
|
it 'fails if username is not specified' do
|
|
|
|
expect { xhr :get, :index }.to raise_error
|
|
|
|
end
|
|
|
|
|
2013-05-26 20:22:37 -04:00
|
|
|
it 'renders list correctly' do
|
|
|
|
ActiveRecord::Base.observers.enable :all
|
|
|
|
post = Fabricate(:post)
|
|
|
|
|
|
|
|
xhr :get, :index, username: post.user.username
|
|
|
|
|
|
|
|
response.status.should == 200
|
|
|
|
parsed = JSON.parse(response.body)
|
|
|
|
actions = parsed["user_actions"]
|
|
|
|
actions.length.should == 1
|
|
|
|
action = actions[0]
|
|
|
|
action["acting_name"].should == post.user.name
|
|
|
|
action["email"].should be_nil
|
2013-06-11 22:23:24 -04:00
|
|
|
action["post_number"].should == 1
|
2013-05-26 20:22:37 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|