2011-02-04 04:13:41 +00:00
|
|
|
require 'spec_helper.rb'
|
|
|
|
|
|
|
|
describe ArticlesController do
|
2011-02-04 15:09:05 +00:00
|
|
|
fixtures :articles,:impressions
|
2011-02-04 04:13:41 +00:00
|
|
|
render_views
|
|
|
|
|
|
|
|
it "should make the impressionable_hash available" do
|
|
|
|
get "index"
|
|
|
|
response.body.include?("false").should eq true
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should log an impression with a message" do
|
|
|
|
get "index"
|
|
|
|
Impression.all.size.should eq 11
|
|
|
|
Article.first.impressions.last.message.should eq "this is a test article impression"
|
|
|
|
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
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe PostsController do
|
|
|
|
it "should log impression at the action level" do
|
|
|
|
get "show", :id=> 1
|
|
|
|
Impression.all.size.should eq 11
|
|
|
|
Impression.last.controller_name.should eq "posts"
|
|
|
|
Impression.last.impressionable_type.should eq "Post"
|
|
|
|
Impression.last.impressionable_id.should eq 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe WidgetsController do
|
|
|
|
it "should log impression at the per action level" do
|
|
|
|
get "show", :id => 1
|
|
|
|
Impression.all.size.should eq 11
|
|
|
|
get "index"
|
|
|
|
Impression.all.size.should eq 12
|
|
|
|
get "new"
|
|
|
|
Impression.all.size.should eq 12
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|