2013-07-06 19:20:35 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe PostsController do
|
2020-07-20 13:35:41 +00:00
|
|
|
it "logs impression at the action level" do
|
|
|
|
get :show, params: { id: 1 }
|
|
|
|
|
|
|
|
expect(Impression.all.size).to eq 12
|
|
|
|
|
|
|
|
impression = Impression.last
|
|
|
|
|
|
|
|
expect(impression.controller_name).to eq "posts"
|
|
|
|
expect(impression.action_name).to eq "show"
|
|
|
|
expect(impression.impressionable_type).to eq "Post"
|
|
|
|
expect(impression.impressionable_id).to eq 1
|
2013-07-06 19:20:35 +00:00
|
|
|
end
|
|
|
|
|
2020-07-20 13:35:41 +00:00
|
|
|
it "logs the user_id if user is authenticated (current_user helper method)" do
|
2013-07-06 19:20:35 +00:00
|
|
|
session[:user_id] = 123
|
2020-07-20 13:35:41 +00:00
|
|
|
get :show, params: { id: 1 }
|
|
|
|
expect(Post.first.impressions.last.user_id).to eq 123
|
2013-07-06 19:20:35 +00:00
|
|
|
end
|
|
|
|
|
2020-07-20 13:35:41 +00:00
|
|
|
it "logs impression at the action level with params" do
|
|
|
|
get :show, params: { id: 1, checked: true }
|
|
|
|
|
|
|
|
expect(Impression.all.size).to eq 12
|
|
|
|
|
|
|
|
impression = Impression.last
|
|
|
|
|
|
|
|
expect(impression.params).to eq({ "checked" => "true" })
|
|
|
|
expect(impression.controller_name).to eq "posts"
|
|
|
|
expect(impression.action_name).to eq "show"
|
|
|
|
expect(impression.impressionable_type).to eq "Post"
|
|
|
|
expect(impression.impressionable_id).to eq 1
|
2015-04-21 10:21:47 +00:00
|
|
|
end
|
2013-07-06 19:20:35 +00:00
|
|
|
end
|