log the controller_name and action_name when impressionist is called manually inside a controller action
This commit is contained in:
parent
993dba1358
commit
7c1ac8ccdc
|
@ -18,7 +18,9 @@ module ImpressionistController
|
||||||
obj.impressions.create(:message=> message,
|
obj.impressions.create(:message=> message,
|
||||||
:request_hash=> @impressionist_hash,
|
:request_hash=> @impressionist_hash,
|
||||||
:ip_address=> request.remote_ip,
|
:ip_address=> request.remote_ip,
|
||||||
:user_id=> user_id)
|
:user_id=> user_id,
|
||||||
|
:controller_name=>controller_name,
|
||||||
|
:action_name=> action_name)
|
||||||
else
|
else
|
||||||
raise "#{obj.class.to_s} is not impressionable!"
|
raise "#{obj.class.to_s} is not impressionable!"
|
||||||
end
|
end
|
||||||
|
@ -47,7 +49,7 @@ module ImpressionistController
|
||||||
private
|
private
|
||||||
def bypass
|
def bypass
|
||||||
Impressionist::Bots::WILD_CARDS.each do |wild_card|
|
Impressionist::Bots::WILD_CARDS.each do |wild_card|
|
||||||
return true if request.user_agent.downcase.include? wild_card
|
return true if request.user_agent and request.user_agent.downcase.include? wild_card
|
||||||
end
|
end
|
||||||
Impressionist::Bots::LIST.include? request.user_agent
|
Impressionist::Bots::LIST.include? request.user_agent
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
PATH
|
PATH
|
||||||
remote: /rails_plugins/mine/impressionist
|
remote: /rails_plugins/mine/impressionist
|
||||||
specs:
|
specs:
|
||||||
impressionist (0.2.2)
|
impressionist (0.2.3)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
|
|
|
@ -13,12 +13,16 @@ describe ArticlesController do
|
||||||
get "index"
|
get "index"
|
||||||
Impression.all.size.should eq 11
|
Impression.all.size.should eq 11
|
||||||
Article.first.impressions.last.message.should eq "this is a test article impression"
|
Article.first.impressions.last.message.should eq "this is a test article impression"
|
||||||
|
Article.first.impressions.last.controller_name.should eq "articles"
|
||||||
|
Article.first.impressions.last.action_name.should eq "index"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should log an impression without a message" do
|
it "should log an impression without a message" do
|
||||||
get "show", :id=> 1
|
get "show", :id=> 1
|
||||||
Impression.all.size.should eq 11
|
Impression.all.size.should eq 11
|
||||||
Article.first.impressions.last.message.should eq nil
|
Article.first.impressions.last.message.should eq nil
|
||||||
|
Article.first.impressions.last.controller_name.should eq "articles"
|
||||||
|
Article.first.impressions.last.action_name.should eq "show"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should log the user_id if user is authenticated (@current_user before_filter method)" do
|
it "should log the user_id if user is authenticated (@current_user before_filter method)" do
|
||||||
|
@ -38,6 +42,7 @@ describe PostsController do
|
||||||
get "show", :id=> 1
|
get "show", :id=> 1
|
||||||
Impression.all.size.should eq 11
|
Impression.all.size.should eq 11
|
||||||
Impression.last.controller_name.should eq "posts"
|
Impression.last.controller_name.should eq "posts"
|
||||||
|
Impression.last.action_name.should eq "show"
|
||||||
Impression.last.impressionable_type.should eq "Post"
|
Impression.last.impressionable_type.should eq "Post"
|
||||||
Impression.last.impressionable_id.should eq 1
|
Impression.last.impressionable_id.should eq 1
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue