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,
|
||||
:request_hash=> @impressionist_hash,
|
||||
:ip_address=> request.remote_ip,
|
||||
:user_id=> user_id)
|
||||
:user_id=> user_id,
|
||||
:controller_name=>controller_name,
|
||||
:action_name=> action_name)
|
||||
else
|
||||
raise "#{obj.class.to_s} is not impressionable!"
|
||||
end
|
||||
|
@ -47,7 +49,7 @@ module ImpressionistController
|
|||
private
|
||||
def bypass
|
||||
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
|
||||
Impressionist::Bots::LIST.include? request.user_agent
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
PATH
|
||||
remote: /rails_plugins/mine/impressionist
|
||||
specs:
|
||||
impressionist (0.2.2)
|
||||
impressionist (0.2.3)
|
||||
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
|
|
|
@ -13,12 +13,16 @@ describe ArticlesController do
|
|||
get "index"
|
||||
Impression.all.size.should eq 11
|
||||
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
|
||||
|
||||
it "should log an impression without a message" do
|
||||
get "show", :id=> 1
|
||||
Impression.all.size.should eq 11
|
||||
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
|
||||
|
||||
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
|
||||
Impression.all.size.should eq 11
|
||||
Impression.last.controller_name.should eq "posts"
|
||||
Impression.last.action_name.should eq "show"
|
||||
Impression.last.impressionable_type.should eq "Post"
|
||||
Impression.last.impressionable_id.should eq 1
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue