2013-05-27 08:22:37 +08:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe UserActionsController do
|
|
|
|
context 'index' do
|
|
|
|
|
2013-05-27 09:02:58 +08:00
|
|
|
it 'fails if username is not specified' do
|
|
|
|
expect { xhr :get, :index }.to raise_error
|
|
|
|
end
|
|
|
|
|
2013-05-27 08:22:37 +08:00
|
|
|
it 'renders list correctly' do
|
|
|
|
ActiveRecord::Base.observers.enable :all
|
|
|
|
post = Fabricate(:post)
|
|
|
|
|
|
|
|
xhr :get, :index, username: post.user.username
|
|
|
|
|
2015-01-10 01:04:02 +08:00
|
|
|
expect(response.status).to eq(200)
|
2013-05-27 08:22:37 +08:00
|
|
|
parsed = JSON.parse(response.body)
|
|
|
|
actions = parsed["user_actions"]
|
2015-01-10 01:04:02 +08:00
|
|
|
expect(actions.length).to eq(1)
|
2013-05-27 08:22:37 +08:00
|
|
|
action = actions[0]
|
2015-01-10 01:04:02 +08:00
|
|
|
expect(action["acting_name"]).to eq(post.user.name)
|
|
|
|
expect(action["email"]).to eq(nil)
|
|
|
|
expect(action["post_number"]).to eq(1)
|
2013-05-27 08:22:37 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|