impressionist 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -1
  3. data/Rakefile +17 -4
  4. data/app/models/impressionist/impressionable.rb +2 -2
  5. data/impressionist.gemspec +4 -3
  6. data/lib/impressionist/engine.rb +8 -25
  7. data/lib/impressionist/load.rb +6 -4
  8. data/lib/impressionist/models/active_record/impression.rb +5 -2
  9. data/lib/impressionist/models/mongoid/impression.rb +8 -15
  10. data/lib/impressionist/models/mongoid/impressionist/impressionable.rb +13 -32
  11. data/lib/impressionist/rails_toggle.rb +22 -0
  12. data/lib/impressionist/setup_association.rb +48 -0
  13. data/lib/impressionist/version.rb +1 -1
  14. data/tests/README +1 -0
  15. data/tests/spec/minitest_helper.rb +4 -0
  16. data/tests/spec/rails_toggle_spec.rb +26 -0
  17. data/tests/spec/setup_association_spec.rb +55 -0
  18. data/{test_app → tests/test_app}/.gitignore +0 -0
  19. data/{test_app → tests/test_app}/.rspec +0 -0
  20. data/{test_app → tests/test_app}/Gemfile +4 -15
  21. data/{test_app → tests/test_app}/README +0 -0
  22. data/{test_app → tests/test_app}/README.rdoc +0 -0
  23. data/{test_app → tests/test_app}/Rakefile +0 -0
  24. data/{test_app → tests/test_app}/app/assets/images/rails.png +0 -0
  25. data/{test_app → tests/test_app}/app/assets/javascripts/application.js +0 -0
  26. data/{test_app → tests/test_app}/app/assets/stylesheets/application.css +0 -0
  27. data/{test_app → tests/test_app}/app/controllers/application_controller.rb +0 -0
  28. data/{test_app → tests/test_app}/app/controllers/articles_controller.rb +0 -0
  29. data/{test_app → tests/test_app}/app/controllers/dummy_controller.rb +0 -0
  30. data/{test_app → tests/test_app}/app/controllers/posts_controller.rb +0 -0
  31. data/{test_app → tests/test_app}/app/controllers/widgets_controller.rb +0 -0
  32. data/{test_app → tests/test_app}/app/helpers/application_helper.rb +0 -0
  33. data/{test_app → tests/test_app}/app/mailers/.gitkeep +0 -0
  34. data/{test_app → tests/test_app}/app/models/.gitkeep +0 -0
  35. data/{test_app → tests/test_app}/app/models/article.rb +0 -0
  36. data/{test_app → tests/test_app}/app/models/dummy.rb +0 -0
  37. data/{test_app → tests/test_app}/app/models/post.rb +0 -0
  38. data/{test_app → tests/test_app}/app/models/user.rb +0 -0
  39. data/{test_app → tests/test_app}/app/models/widget.rb +0 -0
  40. data/{test_app → tests/test_app}/app/views/articles/index.html.erb +0 -0
  41. data/{test_app → tests/test_app}/app/views/articles/show.html.erb +0 -0
  42. data/{test_app → tests/test_app}/app/views/dummy/index.html.erb +0 -0
  43. data/{test_app → tests/test_app}/app/views/layouts/application.html.erb +0 -0
  44. data/{test_app → tests/test_app}/app/views/posts/edit.html.erb +0 -0
  45. data/{test_app → tests/test_app}/app/views/posts/index.html.erb +0 -0
  46. data/{test_app → tests/test_app}/app/views/posts/show.html.erb +0 -0
  47. data/{test_app → tests/test_app}/app/views/widgets/index.html.erb +0 -0
  48. data/{test_app → tests/test_app}/app/views/widgets/new.html.erb +0 -0
  49. data/{test_app → tests/test_app}/app/views/widgets/show.html.erb +0 -0
  50. data/{test_app → tests/test_app}/config.ru +0 -0
  51. data/{test_app → tests/test_app}/config/application.rb +0 -0
  52. data/{test_app → tests/test_app}/config/boot.rb +0 -0
  53. data/{test_app → tests/test_app}/config/cucumber.yml +0 -0
  54. data/{test_app → tests/test_app}/config/database.yml +0 -0
  55. data/{test_app → tests/test_app}/config/environment.rb +0 -0
  56. data/{test_app → tests/test_app}/config/environments/development.rb +0 -0
  57. data/{test_app → tests/test_app}/config/environments/pg_test.rb +0 -0
  58. data/{test_app → tests/test_app}/config/environments/production.rb +0 -0
  59. data/{test_app → tests/test_app}/config/environments/test.rb +0 -0
  60. data/{test_app → tests/test_app}/config/initializers/backtrace_silencers.rb +0 -0
  61. data/tests/test_app/config/initializers/impression.rb +2 -0
  62. data/{test_app → tests/test_app}/config/initializers/inflections.rb +0 -0
  63. data/{test_app → tests/test_app}/config/initializers/mime_types.rb +0 -0
  64. data/{test_app → tests/test_app}/config/initializers/secret_token.rb +0 -0
  65. data/{test_app → tests/test_app}/config/initializers/session_store.rb +0 -0
  66. data/{test_app → tests/test_app}/config/initializers/wrap_parameters.rb +0 -0
  67. data/{test_app → tests/test_app}/config/locales/en.yml +0 -0
  68. data/{test_app → tests/test_app}/config/routes.rb +0 -0
  69. data/{test_app → tests/test_app}/db/migrate/20110201153144_create_articles.rb +0 -0
  70. data/{test_app → tests/test_app}/db/migrate/20110210205028_create_posts.rb +0 -0
  71. data/{test_app → tests/test_app}/db/migrate/20111127184039_create_widgets.rb +0 -0
  72. data/tests/test_app/db/schema.rb +60 -0
  73. data/{test_app → tests/test_app}/db/seeds.rb +0 -0
  74. data/{test_app → tests/test_app}/lib/assets/.gitkeep +0 -0
  75. data/{test_app → tests/test_app}/lib/tasks/.gitkeep +0 -0
  76. data/{test_app → tests/test_app}/lib/tasks/cucumber.rake +0 -0
  77. data/{test_app → tests/test_app}/log/.gitkeep +0 -0
  78. data/{test_app → tests/test_app}/public/404.html +0 -0
  79. data/{test_app → tests/test_app}/public/422.html +0 -0
  80. data/{test_app → tests/test_app}/public/500.html +0 -0
  81. data/{test_app → tests/test_app}/public/favicon.ico +0 -0
  82. data/{test_app → tests/test_app}/public/images/rails.png +0 -0
  83. data/{test_app → tests/test_app}/public/index.html +0 -0
  84. data/{test_app → tests/test_app}/public/javascripts/application.js +0 -0
  85. data/{test_app → tests/test_app}/public/javascripts/controls.js +0 -0
  86. data/{test_app → tests/test_app}/public/javascripts/dragdrop.js +0 -0
  87. data/{test_app → tests/test_app}/public/javascripts/effects.js +0 -0
  88. data/{test_app → tests/test_app}/public/javascripts/prototype.js +0 -0
  89. data/{test_app → tests/test_app}/public/javascripts/rails.js +0 -0
  90. data/{test_app → tests/test_app}/public/robots.txt +0 -0
  91. data/{test_app → tests/test_app}/public/stylesheets/.gitkeep +0 -0
  92. data/{test_app → tests/test_app}/script/cucumber +0 -0
  93. data/{test_app → tests/test_app}/script/rails +0 -0
  94. data/{test_app → tests/test_app}/spec/controllers/articles_controller_spec.rb +0 -0
  95. data/{test_app → tests/test_app}/spec/controllers/dummy_controller_spec.rb +0 -0
  96. data/{test_app → tests/test_app}/spec/controllers/impressionist_uniqueness_spec.rb +45 -45
  97. data/{test_app → tests/test_app}/spec/controllers/posts_controller_spec.rb +0 -0
  98. data/{test_app → tests/test_app}/spec/controllers/widgets_controller_spec.rb +2 -2
  99. data/{test_app → tests/test_app}/spec/fixtures/articles.yml +0 -0
  100. data/{test_app → tests/test_app}/spec/fixtures/impressions.yml +0 -0
  101. data/{test_app → tests/test_app}/spec/fixtures/posts.yml +0 -0
  102. data/{test_app → tests/test_app}/spec/fixtures/widgets.yml +0 -0
  103. data/{test_app → tests/test_app}/spec/initializers/initializers_spec.rb +0 -0
  104. data/{test_app → tests/test_app}/spec/models/bots_spec.rb +0 -0
  105. data/{test_app → tests/test_app}/spec/models/counter_caching_spec.rb +0 -0
  106. data/{test_app → tests/test_app}/spec/models/model_spec.rb +0 -0
  107. data/{test_app → tests/test_app}/spec/rails_generators/rails_generators_spec.rb +0 -0
  108. data/tests/test_app/spec/spec_helper.rb +31 -0
  109. metadata +224 -99
  110. data/lib/impressionist/set_up_association.rb +0 -14
  111. data/spec/spec_helper.rb +0 -5
  112. data/test_app/config/initializers/impression.rb +0 -5
  113. data/test_app/spec/spec_helper.rb +0 -38
File without changes
File without changes
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '3.2.12'
4
4
 
5
- gem 'impressionist', :path => '../'
5
+ gem 'impressionist', :path => '../../'
6
6
 
7
7
  platforms :jruby do
8
8
  gem 'activerecord-jdbcsqlite3-adapter'
@@ -13,6 +13,9 @@ end
13
13
  platforms :ruby, :mswin, :mingw do
14
14
  gem 'pg'
15
15
  gem 'sqlite3'
16
+ gem 'mysql2'
17
+ gem "mongoid", "~> 3.1.4"
18
+ gem 'bson_ext'
16
19
  end
17
20
 
18
21
  gem 'json'
@@ -43,17 +46,3 @@ end
43
46
 
44
47
  gem 'jquery-rails'
45
48
 
46
- # To use ActiveModel has_secure_password
47
- # gem 'bcrypt-ruby', '~> 3.0.0'
48
-
49
- # To use Jbuilder templates for JSON
50
- # gem 'jbuilder'
51
-
52
- # Use unicorn as the app server
53
- # gem 'unicorn'
54
-
55
- # Deploy with Capistrano
56
- # gem 'capistrano'
57
-
58
- # To use debugger
59
- # gem 'ruby-debug'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ # Define ORM. Could be :active_record (default) and :mongo_mapper
2
+ #Impressionist.config.orm = :mongoid
File without changes
File without changes
@@ -0,0 +1,60 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended to check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(:version => 20130709003307) do
15
+
16
+ create_table "articles", :force => true do |t|
17
+ t.string "name"
18
+ t.datetime "created_at", :null => false
19
+ t.datetime "updated_at", :null => false
20
+ end
21
+
22
+ create_table "impressions", :force => true do |t|
23
+ t.string "impressionable_type"
24
+ t.integer "impressionable_id"
25
+ t.integer "user_id"
26
+ t.string "controller_name"
27
+ t.string "action_name"
28
+ t.string "view_name"
29
+ t.string "request_hash"
30
+ t.string "ip_address"
31
+ t.string "session_hash"
32
+ t.text "message"
33
+ t.text "referrer"
34
+ t.datetime "created_at", :null => false
35
+ t.datetime "updated_at", :null => false
36
+ end
37
+
38
+ add_index "impressions", ["controller_name", "action_name", "ip_address"], :name => "controlleraction_ip_index"
39
+ add_index "impressions", ["controller_name", "action_name", "request_hash"], :name => "controlleraction_request_index"
40
+ add_index "impressions", ["controller_name", "action_name", "session_hash"], :name => "controlleraction_session_index"
41
+ add_index "impressions", ["impressionable_type", "impressionable_id", "ip_address"], :name => "poly_ip_index"
42
+ add_index "impressions", ["impressionable_type", "impressionable_id", "request_hash"], :name => "poly_request_index"
43
+ add_index "impressions", ["impressionable_type", "impressionable_id", "session_hash"], :name => "poly_session_index"
44
+ add_index "impressions", ["impressionable_type", "message", "impressionable_id"], :name => "impressionable_type_message_index"
45
+ add_index "impressions", ["user_id"], :name => "index_impressions_on_user_id"
46
+
47
+ create_table "posts", :force => true do |t|
48
+ t.string "name"
49
+ t.datetime "created_at", :null => false
50
+ t.datetime "updated_at", :null => false
51
+ end
52
+
53
+ create_table "widgets", :force => true do |t|
54
+ t.string "name"
55
+ t.integer "impressions_count", :default => 0
56
+ t.datetime "created_at", :null => false
57
+ t.datetime "updated_at", :null => false
58
+ end
59
+
60
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -16,14 +16,14 @@ describe DummyController do
16
16
  end
17
17
 
18
18
  it "should recognize unique session" do
19
- controller.stub!(:session_hash).and_return(request.session_options[:id])
19
+ controller.stub(:session_hash).and_return(request.session_options[:id])
20
20
  controller.impressionist_subapp_filter(nil, [:session_hash])
21
21
  controller.impressionist_subapp_filter(nil, [:session_hash])
22
22
  Impression.should have(@impression_count + 1).records
23
23
  end
24
24
 
25
25
  it "should recognize unique ip" do
26
- controller.request.stub!(:remote_ip).and_return("1.2.3.4")
26
+ controller.request.stub(:remote_ip).and_return("1.2.3.4")
27
27
  controller.impressionist_subapp_filter(nil, [:ip_address])
28
28
  controller.impressionist_subapp_filter(nil, [:ip_address])
29
29
  Impression.should have(@impression_count + 1).records
@@ -36,35 +36,35 @@ describe DummyController do
36
36
  end
37
37
 
38
38
  it "should recognize unique action" do
39
- controller.stub!(:action_name).and_return("test_action")
39
+ controller.stub(:action_name).and_return("test_action")
40
40
  controller.impressionist_subapp_filter(nil, [:action_name])
41
41
  controller.impressionist_subapp_filter(nil, [:action_name])
42
42
  Impression.should have(@impression_count + 1).records
43
43
  end
44
44
 
45
45
  it "should recognize unique controller" do
46
- controller.stub!(:controller_name).and_return("post")
46
+ controller.stub(:controller_name).and_return("post")
47
47
  controller.impressionist_subapp_filter(nil, [:controller_name])
48
48
  controller.impressionist_subapp_filter(nil, [:controller_name])
49
49
  Impression.should have(@impression_count + 1).records
50
50
  end
51
51
 
52
52
  it "should recognize unique user" do
53
- controller.stub!(:user_id).and_return(42)
53
+ controller.stub(:user_id).and_return(42)
54
54
  controller.impressionist_subapp_filter(nil, [:user_id])
55
55
  controller.impressionist_subapp_filter(nil, [:user_id])
56
56
  Impression.should have(@impression_count + 1).records
57
57
  end
58
58
 
59
59
  it "should recognize unique referer" do
60
- controller.request.stub!(:referer).and_return("http://foo/bar")
60
+ controller.request.stub(:referer).and_return("http://foo/bar")
61
61
  controller.impressionist_subapp_filter(nil, [:referrer])
62
62
  controller.impressionist_subapp_filter(nil, [:referrer])
63
63
  Impression.should have(@impression_count + 1).records
64
64
  end
65
65
 
66
66
  it "should recognize unique id" do
67
- controller.stub!(:params).and_return({:id => "666"}) # for correct impressionable id in filter
67
+ controller.stub(:params).and_return({:id => "666"}) # for correct impressionable id in filter
68
68
  controller.impressionist_subapp_filter(nil, [:impressionable_id])
69
69
  controller.impressionist_subapp_filter(nil, [:impressionable_id])
70
70
  Impression.should have(@impression_count + 1).records
@@ -72,88 +72,88 @@ describe DummyController do
72
72
 
73
73
  # extra redundant test for important controller and action combination.
74
74
  it "should recognize different controller and action" do
75
- controller.stub!(:controller_name).and_return("post")
76
- controller.stub!(:action_name).and_return("test_action")
75
+ controller.stub(:controller_name).and_return("post")
76
+ controller.stub(:action_name).and_return("test_action")
77
77
  controller.impressionist_subapp_filter(nil, [:controller_name, :action_name])
78
78
  controller.impressionist_subapp_filter(nil, [:controller_name, :action_name])
79
79
  Impression.should have(@impression_count + 1).records
80
- controller.stub!(:action_name).and_return("another_action")
80
+ controller.stub(:action_name).and_return("another_action")
81
81
  controller.impressionist_subapp_filter(nil, [:controller_name, :action_name])
82
82
  controller.impressionist_subapp_filter(nil, [:controller_name, :action_name])
83
83
  Impression.should have(@impression_count + 2).records
84
- controller.stub!(:controller_name).and_return("article")
84
+ controller.stub(:controller_name).and_return("article")
85
85
  controller.impressionist_subapp_filter(nil, [:controller_name, :action_name])
86
86
  controller.impressionist_subapp_filter(nil, [:controller_name, :action_name])
87
87
  Impression.should have(@impression_count + 3).records
88
88
  end
89
89
 
90
90
  it "should recognize different action" do
91
- controller.stub!(:action_name).and_return("test_action")
91
+ controller.stub(:action_name).and_return("test_action")
92
92
  controller.impressionist_subapp_filter(nil, [:action_name])
93
93
  controller.impressionist_subapp_filter(nil, [:action_name])
94
94
  Impression.should have(@impression_count + 1).records
95
- controller.stub!(:action_name).and_return("another_action")
95
+ controller.stub(:action_name).and_return("another_action")
96
96
  controller.impressionist_subapp_filter(nil, [:action_name])
97
97
  controller.impressionist_subapp_filter(nil, [:action_name])
98
98
  Impression.should have(@impression_count + 2).records
99
99
  end
100
100
 
101
101
  it "should recognize different controller" do
102
- controller.stub!(:controller_name).and_return("post")
102
+ controller.stub(:controller_name).and_return("post")
103
103
  controller.impressionist_subapp_filter(nil, [:controller_name])
104
104
  controller.impressionist_subapp_filter(nil, [:controller_name])
105
105
  Impression.should have(@impression_count + 1).records
106
- controller.stub!(:controller_name).and_return("article")
106
+ controller.stub(:controller_name).and_return("article")
107
107
  controller.impressionist_subapp_filter(nil, [:controller_name])
108
108
  controller.impressionist_subapp_filter(nil, [:controller_name])
109
109
  Impression.should have(@impression_count + 2).records
110
110
  end
111
111
 
112
112
  it "should recognize different session" do
113
- controller.stub!(:session_hash).and_return("foo")
113
+ controller.stub(:session_hash).and_return("foo")
114
114
  controller.impressionist_subapp_filter(nil, [:session_hash])
115
115
  controller.impressionist_subapp_filter(nil, [:session_hash])
116
116
  Impression.should have(@impression_count + 1).records
117
- controller.stub!(:session_hash).and_return("bar")
117
+ controller.stub(:session_hash).and_return("bar")
118
118
  controller.impressionist_subapp_filter(nil, [:session_hash])
119
119
  controller.impressionist_subapp_filter(nil, [:session_hash])
120
120
  Impression.should have(@impression_count + 2).records
121
121
  end
122
122
 
123
123
  it "should recognize different ip" do
124
- controller.request.stub!(:remote_ip).and_return("1.2.3.4")
124
+ controller.request.stub(:remote_ip).and_return("1.2.3.4")
125
125
  controller.impressionist_subapp_filter(nil, [:ip_address])
126
126
  controller.impressionist_subapp_filter(nil, [:ip_address])
127
127
  Impression.should have(@impression_count + 1).records
128
- controller.request.stub!(:remote_ip).and_return("5.6.7.8")
128
+ controller.request.stub(:remote_ip).and_return("5.6.7.8")
129
129
  controller.impressionist_subapp_filter(nil, [:ip_address])
130
130
  controller.impressionist_subapp_filter(nil, [:ip_address])
131
131
  Impression.should have(@impression_count + 2).records
132
132
  end
133
133
 
134
134
  it "should recognize different referer" do
135
- controller.request.stub!(:referer).and_return("http://foo/bar")
135
+ controller.request.stub(:referer).and_return("http://foo/bar")
136
136
  controller.impressionist_subapp_filter(nil, [:referrer])
137
137
  controller.impressionist_subapp_filter(nil, [:referrer])
138
138
  Impression.should have(@impression_count + 1).records
139
- controller.request.stub!(:referer).and_return("http://bar/fo")
139
+ controller.request.stub(:referer).and_return("http://bar/fo")
140
140
  controller.impressionist_subapp_filter(nil, [:referrer])
141
141
  controller.impressionist_subapp_filter(nil, [:referrer])
142
142
  Impression.should have(@impression_count + 2).records
143
143
  end
144
144
 
145
145
  it "should recognize different id" do
146
- controller.stub!(:params).and_return({:id => "666"}) # for correct impressionable id in filter
146
+ controller.stub(:params).and_return({:id => "666"}) # for correct impressionable id in filter
147
147
  controller.impressionist_subapp_filter(nil, [:impressionable_type, :impressionable_id])
148
148
  controller.impressionist_subapp_filter(nil, [:impressionable_type, :impressionable_id])
149
- controller.stub!(:params).and_return({:id => "42"}) # for correct impressionable id in filter
149
+ controller.stub(:params).and_return({:id => "42"}) # for correct impressionable id in filter
150
150
  controller.impressionist_subapp_filter(nil, [:impressionable_type, :impressionable_id])
151
151
  controller.impressionist_subapp_filter(nil, [:impressionable_type, :impressionable_id])
152
152
  Impression.should have(@impression_count + 2).records
153
153
  end
154
154
 
155
155
  it "should recognize combined uniqueness" do
156
- controller.stub!(:action_name).and_return("test_action")
156
+ controller.stub(:action_name).and_return("test_action")
157
157
  controller.impressionist_subapp_filter(nil, [:ip_address, :request_hash, :action_name])
158
158
  controller.impressionist_subapp_filter(nil, [:request_hash, :ip_address, :action_name])
159
159
  controller.impressionist_subapp_filter(nil, [:request_hash, :action_name])
@@ -166,11 +166,11 @@ describe DummyController do
166
166
  end
167
167
 
168
168
  it "should recognize combined non-uniqueness" do
169
- controller.stub!(:action_name).and_return(nil)
169
+ controller.stub(:action_name).and_return(nil)
170
170
  controller.impressionist_subapp_filter(nil, [:ip_address, :action_name])
171
- controller.stub!(:action_name).and_return("test_action")
171
+ controller.stub(:action_name).and_return("test_action")
172
172
  controller.impressionist_subapp_filter(nil, [:ip_address, :action_name])
173
- controller.stub!(:action_name).and_return("another_action")
173
+ controller.stub(:action_name).and_return("another_action")
174
174
  controller.impressionist_subapp_filter(nil, [:ip_address, :action_name])
175
175
  Impression.should have(@impression_count + 3).records
176
176
  end
@@ -189,7 +189,7 @@ describe DummyController do
189
189
  end
190
190
 
191
191
  it "should recognize unique session" do
192
- controller.stub!(:session_hash).and_return(request.session_options[:id])
192
+ controller.stub(:session_hash).and_return(request.session_options[:id])
193
193
  impressionable = Post.create
194
194
  controller.impressionist(impressionable, nil, :unique => [:session_hash])
195
195
  controller.impressionist(impressionable, nil, :unique => [:session_hash])
@@ -197,7 +197,7 @@ describe DummyController do
197
197
  end
198
198
 
199
199
  it "should recognize unique ip" do
200
- controller.request.stub!(:remote_ip).and_return("1.2.3.4")
200
+ controller.request.stub(:remote_ip).and_return("1.2.3.4")
201
201
  impressionable = Post.create
202
202
  controller.impressionist(impressionable, nil, :unique => [:ip_address])
203
203
  controller.impressionist(impressionable, nil, :unique => [:ip_address])
@@ -212,7 +212,7 @@ describe DummyController do
212
212
  end
213
213
 
214
214
  it "should recognize unique user" do
215
- controller.stub!(:user_id).and_return(666)
215
+ controller.stub(:user_id).and_return(666)
216
216
  impressionable = Post.create
217
217
  controller.impressionist(impressionable, nil, :unique => [:user_id])
218
218
  controller.impressionist(impressionable, nil, :unique => [:user_id])
@@ -220,7 +220,7 @@ describe DummyController do
220
220
  end
221
221
 
222
222
  it "should recognize unique referer" do
223
- controller.request.stub!(:referer).and_return("http://foo/bar")
223
+ controller.request.stub(:referer).and_return("http://foo/bar")
224
224
  impressionable = Post.create
225
225
  controller.impressionist(impressionable, nil, :unique => [:referrer])
226
226
  controller.impressionist(impressionable, nil, :unique => [:referrer])
@@ -229,23 +229,23 @@ describe DummyController do
229
229
 
230
230
  it "should recognize different session" do
231
231
  impressionable = Post.create
232
- controller.stub!(:session_hash).and_return("foo")
232
+ controller.stub(:session_hash).and_return("foo")
233
233
  controller.impressionist(impressionable, nil, :unique => [:session_hash])
234
234
  controller.impressionist(impressionable, nil, :unique => [:session_hash])
235
235
  Impression.should have(@impression_count + 1).records
236
- controller.stub!(:session_hash).and_return("bar")
236
+ controller.stub(:session_hash).and_return("bar")
237
237
  controller.impressionist(impressionable, nil, :unique => [:session_hash])
238
238
  controller.impressionist(impressionable, nil, :unique => [:session_hash])
239
239
  Impression.should have(@impression_count + 2).records
240
240
  end
241
241
 
242
242
  it "should recognize different ip" do
243
- controller.request.stub!(:remote_ip).and_return("1.2.3.4")
243
+ controller.request.stub(:remote_ip).and_return("1.2.3.4")
244
244
  impressionable = Post.create
245
245
  controller.impressionist(impressionable, nil, :unique => [:ip_address])
246
246
  controller.impressionist(impressionable, nil, :unique => [:ip_address])
247
247
  Impression.should have(@impression_count + 1).records
248
- controller.request.stub!(:remote_ip).and_return("5.6.7.8")
248
+ controller.request.stub(:remote_ip).and_return("5.6.7.8")
249
249
  controller.impressionist(impressionable, nil, :unique => [:ip_address])
250
250
  controller.impressionist(impressionable, nil, :unique => [:ip_address])
251
251
  Impression.should have(@impression_count + 2).records
@@ -253,11 +253,11 @@ describe DummyController do
253
253
 
254
254
  it "should recognize different user" do
255
255
  impressionable = Post.create
256
- controller.stub!(:user_id).and_return(666)
256
+ controller.stub(:user_id).and_return(666)
257
257
  controller.impressionist(impressionable, nil, :unique => [:user_id])
258
258
  controller.impressionist(impressionable, nil, :unique => [:user_id])
259
259
  Impression.should have(@impression_count + 1).records
260
- controller.stub!(:user_id).and_return(42)
260
+ controller.stub(:user_id).and_return(42)
261
261
  controller.impressionist(impressionable, nil, :unique => [:user_id])
262
262
  controller.impressionist(impressionable, nil, :unique => [:user_id])
263
263
  Impression.should have(@impression_count + 2).records
@@ -265,7 +265,7 @@ describe DummyController do
265
265
 
266
266
  it "should recognize combined uniqueness" do
267
267
  impressionable = Post.create
268
- controller.stub!(:session_hash).and_return("foo")
268
+ controller.stub(:session_hash).and_return("foo")
269
269
  controller.impressionist(impressionable, nil, :unique => [:ip_address, :request_hash, :session_hash])
270
270
  controller.impressionist(impressionable, nil, :unique => [:request_hash, :ip_address, :session_hash])
271
271
  controller.impressionist(impressionable, nil, :unique => [:request_hash, :session_hash])
@@ -279,11 +279,11 @@ describe DummyController do
279
279
 
280
280
  it "should recognize combined non-uniqueness" do
281
281
  impressionable = Post.create
282
- controller.stub!(:session_hash).and_return(nil)
282
+ controller.stub(:session_hash).and_return(nil)
283
283
  controller.impressionist(impressionable, nil, :unique => [:ip_address, :session_hash])
284
- controller.stub!(:session_hash).and_return("foo")
284
+ controller.stub(:session_hash).and_return("foo")
285
285
  controller.impressionist(impressionable, nil, :unique => [:ip_address, :session_hash])
286
- controller.stub!(:session_hash).and_return("bar")
286
+ controller.stub(:session_hash).and_return("bar")
287
287
  controller.impressionist(impressionable, nil, :unique => [:ip_address, :session_hash])
288
288
  Impression.should have(@impression_count + 3).records
289
289
  end
@@ -294,10 +294,10 @@ describe DummyController do
294
294
 
295
295
  it "should recognize uniqueness" do
296
296
  impressionable = Post.create
297
- controller.stub!(:controller_name).and_return("posts") # for correct impressionable type in filter
298
- controller.stub!(:params).and_return({:id => impressionable.id.to_s}) # for correct impressionable id in filter
299
- controller.stub!(:session_hash).and_return("foo")
300
- controller.request.stub!(:remote_ip).and_return("1.2.3.4")
297
+ controller.stub(:controller_name).and_return("posts") # for correct impressionable type in filter
298
+ controller.stub(:params).and_return({:id => impressionable.id.to_s}) # for correct impressionable id in filter
299
+ controller.stub(:session_hash).and_return("foo")
300
+ controller.request.stub(:remote_ip).and_return("1.2.3.4")
301
301
  # order of the following methods is important for the test!
302
302
  controller.impressionist_subapp_filter(nil, [:ip_address, :request_hash, :session_hash])
303
303
  controller.impressionist(impressionable, nil, :unique => [:ip_address, :request_hash, :session_hash])