impressionist2 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +26 -0
  5. data/CHANGELOG.rdoc +82 -0
  6. data/Gemfile +26 -0
  7. data/LICENSE.txt +20 -0
  8. data/README.md +250 -0
  9. data/Rakefile +34 -0
  10. data/app/controllers/impressionist_controller.rb +146 -0
  11. data/app/models/impression.rb +2 -0
  12. data/app/models/impressionist/bots.rb +1468 -0
  13. data/app/models/impressionist/impressionable.rb +62 -0
  14. data/gemfiles/rails32.gemfile +30 -0
  15. data/gemfiles/rails40.gemfile +30 -0
  16. data/gemfiles/rails50.gemfile +30 -0
  17. data/impressionist2.gemspec +23 -0
  18. data/lib/generators/active_record/impressionist_generator.rb +22 -0
  19. data/lib/generators/active_record/templates/create_impressions_table.rb +32 -0
  20. data/lib/generators/impressionist_generator.rb +13 -0
  21. data/lib/generators/mongo_mapper/impressionist_generator.rb +8 -0
  22. data/lib/generators/mongoid/impressionist_generator.rb +8 -0
  23. data/lib/generators/templates/impression.rb +8 -0
  24. data/lib/impressionist/bots.rb +21 -0
  25. data/lib/impressionist/controllers/mongoid/impressionist_controller.rb +10 -0
  26. data/lib/impressionist/counter_cache.rb +73 -0
  27. data/lib/impressionist/engine.rb +30 -0
  28. data/lib/impressionist/is_impressionable.rb +23 -0
  29. data/lib/impressionist/load.rb +11 -0
  30. data/lib/impressionist/models/active_record/impression.rb +14 -0
  31. data/lib/impressionist/models/active_record/impressionist/impressionable.rb +12 -0
  32. data/lib/impressionist/models/mongo_mapper/impression.rb +18 -0
  33. data/lib/impressionist/models/mongo_mapper/impressionist/impressionable.rb +21 -0
  34. data/lib/impressionist/models/mongoid/impression.rb +25 -0
  35. data/lib/impressionist/models/mongoid/impressionist/impressionable.rb +28 -0
  36. data/lib/impressionist/rails_toggle.rb +26 -0
  37. data/lib/impressionist/setup_association.rb +49 -0
  38. data/lib/impressionist/update_counters.rb +69 -0
  39. data/lib/impressionist/version.rb +3 -0
  40. data/lib/impressionist.rb +12 -0
  41. data/logo.png +0 -0
  42. data/tests/README +11 -0
  43. data/tests/spec/minitest_helper.rb +4 -0
  44. data/tests/spec/rails_toggle_spec.rb +38 -0
  45. data/tests/spec/setup_association_spec.rb +56 -0
  46. data/tests/test_app/.gitignore +18 -0
  47. data/tests/test_app/.rspec +1 -0
  48. data/tests/test_app/Gemfile +51 -0
  49. data/tests/test_app/README +256 -0
  50. data/tests/test_app/README.rdoc +261 -0
  51. data/tests/test_app/Rakefile +7 -0
  52. data/tests/test_app/app/assets/images/rails.png +0 -0
  53. data/tests/test_app/app/assets/javascripts/application.js +13 -0
  54. data/tests/test_app/app/assets/stylesheets/application.css +13 -0
  55. data/tests/test_app/app/controllers/application_controller.rb +8 -0
  56. data/tests/test_app/app/controllers/articles_controller.rb +18 -0
  57. data/tests/test_app/app/controllers/dummy_controller.rb +8 -0
  58. data/tests/test_app/app/controllers/posts_controller.rb +23 -0
  59. data/tests/test_app/app/controllers/profiles_controller.rb +14 -0
  60. data/tests/test_app/app/controllers/widgets_controller.rb +12 -0
  61. data/tests/test_app/app/helpers/application_helper.rb +2 -0
  62. data/tests/test_app/app/mailers/.gitkeep +0 -0
  63. data/tests/test_app/app/models/.gitkeep +0 -0
  64. data/tests/test_app/app/models/article.rb +3 -0
  65. data/tests/test_app/app/models/dummy.rb +7 -0
  66. data/tests/test_app/app/models/post.rb +3 -0
  67. data/tests/test_app/app/models/profile.rb +6 -0
  68. data/tests/test_app/app/models/user.rb +3 -0
  69. data/tests/test_app/app/models/widget.rb +3 -0
  70. data/tests/test_app/app/views/articles/index.html.erb +1 -0
  71. data/tests/test_app/app/views/articles/show.html.erb +1 -0
  72. data/tests/test_app/app/views/dummy/index.html.erb +0 -0
  73. data/tests/test_app/app/views/layouts/application.html.erb +14 -0
  74. data/tests/test_app/app/views/posts/edit.html.erb +0 -0
  75. data/tests/test_app/app/views/posts/index.html.erb +0 -0
  76. data/tests/test_app/app/views/posts/show.html.erb +0 -0
  77. data/tests/test_app/app/views/profiles/show.html.erb +3 -0
  78. data/tests/test_app/app/views/widgets/index.html.erb +0 -0
  79. data/tests/test_app/app/views/widgets/new.html.erb +0 -0
  80. data/tests/test_app/app/views/widgets/show.html.erb +0 -0
  81. data/tests/test_app/config/application.rb +59 -0
  82. data/tests/test_app/config/boot.rb +6 -0
  83. data/tests/test_app/config/cucumber.yml +8 -0
  84. data/tests/test_app/config/database.yml +30 -0
  85. data/tests/test_app/config/environment.rb +5 -0
  86. data/tests/test_app/config/environments/development.rb +37 -0
  87. data/tests/test_app/config/environments/pg_test.rb +35 -0
  88. data/tests/test_app/config/environments/production.rb +67 -0
  89. data/tests/test_app/config/environments/test.rb +37 -0
  90. data/tests/test_app/config/initializers/backtrace_silencers.rb +7 -0
  91. data/tests/test_app/config/initializers/impression.rb +8 -0
  92. data/tests/test_app/config/initializers/inflections.rb +15 -0
  93. data/tests/test_app/config/initializers/mime_types.rb +5 -0
  94. data/tests/test_app/config/initializers/secret_token.rb +7 -0
  95. data/tests/test_app/config/initializers/session_store.rb +8 -0
  96. data/tests/test_app/config/initializers/wrap_parameters.rb +14 -0
  97. data/tests/test_app/config/locales/en.yml +5 -0
  98. data/tests/test_app/config/routes.rb +4 -0
  99. data/tests/test_app/config.ru +4 -0
  100. data/tests/test_app/db/migrate/20110201153144_create_articles.rb +13 -0
  101. data/tests/test_app/db/migrate/20110210205028_create_posts.rb +13 -0
  102. data/tests/test_app/db/migrate/20111127184039_create_widgets.rb +15 -0
  103. data/tests/test_app/db/migrate/20130719024021_create_impressions_table.rb +32 -0
  104. data/tests/test_app/db/migrate/20150207135825_create_profiles.rb +10 -0
  105. data/tests/test_app/db/migrate/20150207140310_create_friendly_id_slugs.rb +18 -0
  106. data/tests/test_app/db/schema.rb +80 -0
  107. data/tests/test_app/db/seeds.rb +7 -0
  108. data/tests/test_app/lib/assets/.gitkeep +0 -0
  109. data/tests/test_app/lib/tasks/.gitkeep +0 -0
  110. data/tests/test_app/lib/tasks/cucumber.rake +53 -0
  111. data/tests/test_app/log/.gitkeep +0 -0
  112. data/tests/test_app/public/404.html +26 -0
  113. data/tests/test_app/public/422.html +26 -0
  114. data/tests/test_app/public/500.html +25 -0
  115. data/tests/test_app/public/favicon.ico +0 -0
  116. data/tests/test_app/public/images/rails.png +0 -0
  117. data/tests/test_app/public/index.html +241 -0
  118. data/tests/test_app/public/javascripts/application.js +2 -0
  119. data/tests/test_app/public/javascripts/controls.js +965 -0
  120. data/tests/test_app/public/javascripts/dragdrop.js +974 -0
  121. data/tests/test_app/public/javascripts/effects.js +1123 -0
  122. data/tests/test_app/public/javascripts/prototype.js +6001 -0
  123. data/tests/test_app/public/javascripts/rails.js +175 -0
  124. data/tests/test_app/public/robots.txt +5 -0
  125. data/tests/test_app/public/stylesheets/.gitkeep +0 -0
  126. data/tests/test_app/script/cucumber +10 -0
  127. data/tests/test_app/script/rails +6 -0
  128. data/tests/test_app/spec/controllers/articles_controller_spec.rb +76 -0
  129. data/tests/test_app/spec/controllers/dummy_controller_spec.rb +11 -0
  130. data/tests/test_app/spec/controllers/impressionist_uniqueness_spec.rb +396 -0
  131. data/tests/test_app/spec/controllers/posts_controller_spec.rb +28 -0
  132. data/tests/test_app/spec/controllers/widgets_controller_spec.rb +91 -0
  133. data/tests/test_app/spec/fixtures/articles.yml +3 -0
  134. data/tests/test_app/spec/fixtures/impressions.yml +43 -0
  135. data/tests/test_app/spec/fixtures/posts.yml +3 -0
  136. data/tests/test_app/spec/fixtures/profiles.yml +4 -0
  137. data/tests/test_app/spec/fixtures/widgets.yml +4 -0
  138. data/tests/test_app/spec/initializers/initializers_spec.rb +20 -0
  139. data/tests/test_app/spec/models/bots_spec.rb +27 -0
  140. data/tests/test_app/spec/models/counter_caching_spec.rb +51 -0
  141. data/tests/test_app/spec/models/model_spec.rb +70 -0
  142. data/tests/test_app/spec/rails_generators/rails_generators_spec.rb +23 -0
  143. data/tests/test_app/spec/spec_helper.rb +43 -0
  144. data/upgrade_migrations/version_0_3_0.rb +27 -0
  145. data/upgrade_migrations/version_0_4_0.rb +9 -0
  146. metadata +314 -0
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe PostsController do
4
+ it "should log impression at the action level" do
5
+ get "show", :id=> 1
6
+ Impression.all.size.should eq 12
7
+ Impression.last.controller_name.should eq "posts"
8
+ Impression.last.action_name.should eq "show"
9
+ Impression.last.impressionable_type.should eq "Post"
10
+ Impression.last.impressionable_id.should eq 1
11
+ end
12
+
13
+ it "should log the user_id if user is authenticated (current_user helper method)" do
14
+ session[:user_id] = 123
15
+ get "show", :id=> 1
16
+ Post.first.impressions.last.user_id.should eq 123
17
+ end
18
+
19
+ it "should log impression at the action level with params" do
20
+ get "show", id: 1, checked: true
21
+ Impression.all.size.should eq 12
22
+ Impression.last.params.should eq({"checked"=>true})
23
+ Impression.last.controller_name.should eq "posts"
24
+ Impression.last.action_name.should eq "show"
25
+ Impression.last.impressionable_type.should eq "Post"
26
+ Impression.last.impressionable_id.should eq 1
27
+ end
28
+ end
@@ -0,0 +1,91 @@
1
+ require 'spec_helper'
2
+
3
+ describe WidgetsController do
4
+
5
+ before(:each) do
6
+ @widget = Widget.find(1)
7
+ Widget.stub(:find).and_return(@widget)
8
+ end
9
+
10
+ it "should log impression at the per action level" do
11
+ get "show", :id=> 1
12
+ Impression.all.size.should eq 12
13
+ get "index"
14
+ Impression.all.size.should eq 13
15
+ get "new"
16
+ Impression.all.size.should eq 13
17
+ end
18
+
19
+ it "should not log impression when user-agent is in wildcard list" do
20
+ request.stub(:user_agent).and_return('somebot')
21
+ get "show", :id=> 1
22
+ Impression.all.size.should eq 11
23
+ end
24
+
25
+ it "should not log impression when user-agent is in the bot list" do
26
+ request.stub(:user_agent).and_return('Acoon Robot v1.50.001')
27
+ get "show", :id=> 1
28
+ Impression.all.size.should eq 11
29
+ end
30
+
31
+ context "impressionist unique options" do
32
+
33
+ it "should log unique impressions at the per action level" do
34
+ get "show", :id=> 1
35
+ Impression.all.size.should eq 12
36
+ get "show", :id=> 2
37
+ Impression.all.size.should eq 13
38
+ get "show", :id => 2
39
+ Impression.all.size.should eq 13
40
+ get "index"
41
+ Impression.all.size.should eq 14
42
+ end
43
+
44
+ it "should log unique impressions only once per id" do
45
+ get "show", :id=> 1
46
+ Impression.all.size.should eq 12
47
+ get "show", :id=> 2
48
+ Impression.all.size.should eq 13
49
+
50
+ get "show", :id => 2
51
+ Impression.all.size.should eq 13
52
+
53
+ get "index"
54
+ Impression.all.size.should eq 14
55
+ end
56
+
57
+ end
58
+
59
+ context "Impresionist unique params options" do
60
+ it "should log unique impressions at the per action and params level" do
61
+ get "show", :id => 1
62
+ Impression.all.size.should eq 12
63
+ get "show", :id => 2, checked: true
64
+ Impression.all.size.should eq 13
65
+ get "show", :id => 2, checked: false
66
+ Impression.all.size.should eq 14
67
+ get "index"
68
+ Impression.all.size.should eq 15
69
+ end
70
+
71
+ it "should not log impression for same params and same id" do
72
+ get "show", :id => 1
73
+ Impression.all.size.should eq 12
74
+ get "show", :id => 1
75
+ Impression.all.size.should eq 12
76
+ get "show", :id => 1, checked: true
77
+ Impression.all.size.should eq 13
78
+ get "show", :id => 1, checked: false
79
+ Impression.all.size.should eq 14
80
+ get "show", :id => 1, checked: true
81
+ Impression.all.size.should eq 14
82
+ get "show", :id => 1, checked: false
83
+ Impression.all.size.should eq 14
84
+ get "show", :id => 1
85
+ Impression.all.size.should eq 14
86
+ get "show", :id => 2
87
+ Impression.all.size.should eq 15
88
+ end
89
+ end
90
+
91
+ end
@@ -0,0 +1,3 @@
1
+ one:
2
+ id: 1
3
+ name: Test Article
@@ -0,0 +1,43 @@
1
+ <% 1.upto(7) do |i| %>
2
+ impression<%= i %>:
3
+ impressionable_type: Article
4
+ impressionable_id: 1
5
+ request_hash: a<%=i%>
6
+ session_hash: b<%=i%>
7
+ ip_address: 127.0.0.<%=i%>
8
+ created_at: 2011-01-01
9
+ <% end %>
10
+
11
+
12
+ impression8:
13
+ impressionable_type: Article
14
+ impressionable_id: 1
15
+ request_hash: a1
16
+ session_hash: b1
17
+ ip_address: 127.0.0.1
18
+ created_at: 2010-01-01
19
+
20
+ impression9:
21
+ impressionable_type: Article
22
+ impressionable_id: 1
23
+ request_hash: a1
24
+ session_hash: b2
25
+ ip_address: 127.0.0.1
26
+ created_at: 2011-01-03
27
+
28
+ impression10:
29
+ impressionable_type: Article
30
+ impressionable_id: 1
31
+ request_hash: a9
32
+ session_hash: b3
33
+ ip_address: 127.0.0.8
34
+ created_at: 2010-01-01
35
+
36
+ impression11:
37
+ impressionable_type: Article
38
+ impressionable_id: 1
39
+ request_hash: a10
40
+ session_hash: b4
41
+ ip_address: 127.0.0.1
42
+ created_at: 2010-01-01
43
+
@@ -0,0 +1,3 @@
1
+ one:
2
+ id: 1
3
+ name: Test Post
@@ -0,0 +1,4 @@
1
+ one:
2
+ id: 1
3
+ username: test_profile
4
+ slug: test_profile
@@ -0,0 +1,4 @@
1
+ one:
2
+ id: 1
3
+ name: A Widget
4
+ impressions_count: 0
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Impressionist do
4
+ let(:imp) { RUBY_VERSION.match("1.8") ? "is_impressionable" : :is_impressionable }
5
+
6
+ it "should be extended from ActiveRecord::Base" do
7
+ expect(ActiveRecord::Base).to respond_to(imp)
8
+ #ActiveRecord::Base.methods.include?(method).should be_true
9
+ end
10
+
11
+ it "should include methods in ApplicationController" do
12
+ method = RUBY_VERSION.match("1.8") ? "impressionist" : :impressionist
13
+ expect(ApplicationController).to respond_to(method)
14
+ end
15
+
16
+ it "should include the before_filter method in ApplicationController" do
17
+ filters = ApplicationController._process_action_callbacks.select { |c| c.kind == :before }
18
+ filters.collect{|filter|filter.filter}.include?(:impressionist_app_filter).should be_true
19
+ end
20
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Impressionist::Bots do
4
+
5
+ describe "self.bot?" do
6
+ it "is true if user_agent is matches wild card" do
7
+ Impressionist::Bots.bot?("google.com bot").should be_true
8
+ end
9
+
10
+ it "is true if user_agent is on bot list" do
11
+ Impressionist::Bots.bot?("A-Online Search").should be_true
12
+ end
13
+
14
+ it "is false if user_agent is blank" do
15
+ Impressionist::Bots.bot?("").should be_false
16
+ Impressionist::Bots.bot?(nil).should be_false
17
+ end
18
+
19
+ it "is false if user_agent is safe" do
20
+ Impressionist::Bots.bot?('127.0.0.1').should be_false
21
+ end
22
+
23
+ it "is false if user_agent not given" do
24
+ Impressionist::Bots.bot?.should be_false
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe Impression do
4
+ fixtures :widgets
5
+
6
+ let(:widget) { Widget.find(1) }
7
+
8
+ before(:each) do
9
+ Impression.destroy_all
10
+ end
11
+
12
+ describe "self#impressionist_counter_caching?" do
13
+ it "should know when counter caching is enabled" do
14
+ Widget.should be_impressionist_counter_caching
15
+ end
16
+
17
+ it "should know when counter caching is disabled" do
18
+ Article.should_not be_impressionist_counter_caching
19
+ end
20
+ end
21
+
22
+ describe "self#counter_caching?" do
23
+ it "should know when counter caching is enabled" do
24
+ ActiveSupport::Deprecation.should_receive(:warn)
25
+ Widget.should be_counter_caching
26
+ end
27
+
28
+ it "should know when counter caching is disabled" do
29
+ ActiveSupport::Deprecation.should_receive(:warn)
30
+ Article.should_not be_counter_caching
31
+ end
32
+
33
+ end
34
+
35
+ describe "#update_impressionist_counter_cache" do
36
+ it "should update the counter cache column to reflect the correct number of impressions" do
37
+ expect {
38
+ widget.impressions.create(:request_hash => 'abcd1234')
39
+ widget.reload
40
+ }.to change(widget, :impressions_count).from(0).to(1)
41
+ end
42
+
43
+ it "should not update the timestamp on the impressable" do
44
+ expect {
45
+ widget.impressions.create(:request_hash => 'abcd1234')
46
+ widget.reload
47
+ }.to_not change(widget, :updated_at)
48
+ end
49
+ end
50
+
51
+ end
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ describe Impression do
4
+ fixtures :articles,:impressions,:posts,:profiles
5
+
6
+ before(:each) do
7
+ @article = Article.find(1)
8
+ end
9
+
10
+ it "should save a blank impression for an Article that has 10 impressions" do
11
+ @article.impressions.create
12
+ @article.impressions.size.should eq 12
13
+ end
14
+
15
+ it "should save an impression with a message" do
16
+ @article.impressions.create(:message=>"test message")
17
+ @article.impressions.last.message.should eq "test message"
18
+ end
19
+
20
+ it "should return the impression count for the message specified" do
21
+ @article.impressions.create(:message => "pageview")
22
+ @article.impressions.create(:message => "pageview")
23
+ @article.impressions.create(:message => "visit")
24
+
25
+ @article.impressionist_count(:message => "pageview", :filter => :all).should eq 2
26
+ end
27
+
28
+ it "should return the impression count for all with no date range specified" do
29
+ @article.impressionist_count(:filter=>:all).should eq 11
30
+ end
31
+
32
+ it "should return unique impression count with no date range specified" do
33
+ @article.impressionist_count.should eq 9
34
+ end
35
+
36
+ it "should return impression count with only start date specified" do
37
+ @article.impressionist_count(:start_date=>"2011-01-01",:filter=>:all).should eq 8
38
+ end
39
+
40
+ it "should return impression count with whole date range specified" do
41
+ @article.impressionist_count(:start_date=>"2011-01-01",:end_date=>"2011-01-02",:filter=>:all).should eq 7
42
+ end
43
+
44
+ it "should return unique impression count with only start date specified" do
45
+ @article.impressionist_count(:start_date=>"2011-01-01").should eq 7
46
+ end
47
+
48
+ it "should return unique impression count with date range specified" do
49
+ @article.impressionist_count(:start_date=>"2011-01-01",:end_date=>"2011-01-02").should eq 7
50
+ end
51
+
52
+ it "should return unique impression count using ip address (which in turn eliminates duplicate request_hashes)" do
53
+ @article.impressionist_count(:filter=>:ip_address).should eq 8
54
+ end
55
+
56
+ it "should return unique impression count using session_hash (which in turn eliminates duplicate request_hashes)" do
57
+ @article.impressionist_count(:filter=>:session_hash).should eq 7
58
+ end
59
+
60
+ # tests :dependent => :destroy
61
+ it "should delete impressions on deletion of impressionable" do
62
+ #impressions_count = Impression.all.size
63
+ a = Article.create
64
+ i = a.impressions.create
65
+ a.destroy
66
+ a.destroyed?.should be_true
67
+ i.destroyed?.should be_true
68
+ end
69
+
70
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+ require 'systemu'
3
+
4
+ # FIXME this test might break the others if run before them
5
+ # started fixing @nbit001
6
+ describe Impressionist, :migration do
7
+ fixtures :articles,:impressions,:posts,:profiles
8
+ it "should delete existing migration and generate the migration file" do
9
+ pending
10
+ migrations_dir = "#{Rails.root}/db/migrate"
11
+ impressions_migration = Dir.entries(migrations_dir).grep(/impressions/)[0]
12
+ File.delete("#{migrations_dir}/#{impressions_migration}") unless impressions_migration.blank?
13
+ generator_output = systemu("rails g impressionist")[1]
14
+ migration_name = generator_output.split("migrate/")[1].strip
15
+ Dir.entries(migrations_dir).include?(migration_name).should be_true
16
+ end
17
+
18
+ it "should run the migration created in the previous spec" do
19
+ pending
20
+ migrate_output = systemu("rake db:migrate RAILS_ENV=test")
21
+ migrate_output[1].include?("CreateImpressionsTable: migrated").should be_true
22
+ end
23
+ end
@@ -0,0 +1,43 @@
1
+ ENV["RAILS_ENV"] ||= 'test'
2
+
3
+ unless ENV['CI']
4
+ require 'simplecov'
5
+ SimpleCov.start 'rails'
6
+ end
7
+
8
+ require File.
9
+ expand_path("../../config/environment", __FILE__)
10
+
11
+ require 'rspec/rails'
12
+ require 'capybara/rails'
13
+
14
+ # Custom matchers and macros, etc...
15
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f|
16
+ require f
17
+ }
18
+
19
+ RSpec.configure do |config|
20
+
21
+ # in order to pass tags(symbols) as true values
22
+ # you need to tell rspec to do so by
23
+ config.treat_symbols_as_metadata_keys_with_true_values = true
24
+
25
+ config.mock_with :rspec
26
+
27
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
28
+
29
+ config.use_transactional_fixtures = true
30
+
31
+ # excludes migration tag while running app base tests
32
+ config.filter_run_excluding :migration => true
33
+
34
+ # self explanatory
35
+ # runs everything
36
+ config.run_all_when_everything_filtered = true
37
+
38
+ # make the rails logger usable in the tests as logger.xxx "..."
39
+ def logger
40
+ Rails.logger
41
+ end
42
+
43
+ end
@@ -0,0 +1,27 @@
1
+ class CreateImpressionsTable < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :impressions, :session_hash, :string
4
+ remove_index :impressions, :name => :poly_index
5
+ remove_index :impressions, :name => :controlleraction_index
6
+ add_index :impressions, [:impressionable_type, :impressionable_id, :request_hash], :name => "poly_request_index", :unique => false
7
+ add_index :impressions, [:impressionable_type, :impressionable_id, :ip_address], :name => "poly_ip_index", :unique => false
8
+ add_index :impressions, [:impressionable_type, :impressionable_id, :session_hash], :name => "poly_session_index", :unique => false
9
+ add_index :impressions, [:controller_name,:action_name,:request_hash], :name => "controlleraction_request_index", :unique => false
10
+ add_index :impressions, [:controller_name,:action_name,:ip_address], :name => "controlleraction_ip_index", :unique => false
11
+ add_index :impressions, [:controller_name,:action_name,:session_hash], :name => "controlleraction_session_index", :unique => false
12
+
13
+ end
14
+
15
+ def self.down
16
+ remove_column :impressions, :session_hash
17
+ remove_index :impressions, :name => :poly_request_index
18
+ remove_index :impressions, :name => :poly_ip_index
19
+ remove_index :impressions, :name => :poly_session_index
20
+ remove_index :impressions, :name => :controlleraction_request_index
21
+ remove_index :impressions, :name => :controlleraction_ip_index
22
+ remove_index :impressions, :name => :controlleraction_session_index
23
+ remove_index :impressions, :user_id
24
+ add_index :impressions, [:impressionable_type, :impressionable_id, :request_hash, :ip_address], :name => "poly_index", :unique => false
25
+ add_index :impressions, [:controller_name,:action_name,:request_hash,:ip_address], :name => "controlleraction_index", :unique => false
26
+ end
27
+ end
@@ -0,0 +1,9 @@
1
+ class Version04UpdateImpressionsTable < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :impressions, :referrer, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :impressions, :referrer
8
+ end
9
+ end