Sha256: 40450822dd091ecab22a4ea2e8f5cbe9786f408647225890f2d763244deb677e

Contents?: true

Size: 1.93 KB

Versions: 14

Compression:

Stored size: 1.93 KB

Contents

require 'spec_helper'

describe ArticlesController do
  fixtures :articles,:impressions,:posts,:widgets

  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 12
    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 12
    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
    session[:user_id] = 123
    get "show", :id=> 1
    Article.first.impressions.last.user_id.should eq 123
  end

  it "should not log the user_id if user is authenticated" do
    get "show", :id=> 1
    Article.first.impressions.last.user_id.should eq nil
  end

  it "should log the request_hash, ip_address, referrer and session_hash" do
    get "show", :id=> 1
    Impression.last.request_hash.size.should eq 64
    Impression.last.ip_address.should eq "0.0.0.0"
    Impression.last.session_hash.size.should eq 32
    Impression.last.referrer.should eq nil
  end

  # Capybara has change the way it works
  # We need to pass :type options in order to make include helper methods
  # see https://github.com/jnicklas/capybara#using-capybara-with-rspec
  it "should log the referrer when you click a link", :type => :feature do
    visit article_url(Article.first)
    click_link "Same Page"
    Impression.last.referrer.should eq "http://test.host/articles/1"
  end
end




Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
impressionist-1.5.1 tests/test_app/spec/controllers/articles_controller_spec.rb
impressionist-1.4.13 tests/test_app/spec/controllers/articles_controller_spec.rb
impressionist-1.4.12 tests/test_app/spec/controllers/articles_controller_spec.rb
impressionist-1.4.11 tests/test_app/spec/controllers/articles_controller_spec.rb
impressionist-1.4.10 tests/test_app/spec/controllers/articles_controller_spec.rb
impressionist-1.4.9 tests/test_app/spec/controllers/articles_controller_spec.rb
impressionist-1.4.8 tests/test_app/spec/controllers/articles_controller_spec.rb
impressionist-1.4.7 tests/test_app/spec/controllers/articles_controller_spec.rb
impressionist-1.4.6 tests/test_app/spec/controllers/articles_controller_spec.rb
impressionist-1.4.5 tests/test_app/spec/controllers/articles_controller_spec.rb
impressionist-1.4.4 tests/test_app/spec/controllers/articles_controller_spec.rb
impressionist-1.4.3 tests/test_app/spec/controllers/articles_controller_spec.rb
impressionist-1.4.2 tests/test_app/spec/controllers/articles_controller_spec.rb
impressionist-1.4.1 test_app/spec/controllers/articles_controller_spec.rb