impressionist-cody 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/main.yml +25 -0
  3. data/.gitignore +17 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +27 -0
  6. data/.rubocop_todo.yml +660 -0
  7. data/CHANGELOG.rdoc +96 -0
  8. data/Gemfile +22 -0
  9. data/LICENSE.txt +20 -0
  10. data/README.md +265 -0
  11. data/Rakefile +20 -0
  12. data/UPGRADE_GUIDE.md +13 -0
  13. data/app/assets/config/manifest.js +3 -0
  14. data/app/controllers/impressionist_controller.rb +166 -0
  15. data/app/models/impression.rb +2 -0
  16. data/app/models/impressionist/bots.rb +1468 -0
  17. data/app/models/impressionist/impressionable.rb +62 -0
  18. data/impressionist.gemspec +30 -0
  19. data/lib/generators/active_record/impressionist_generator.rb +22 -0
  20. data/lib/generators/active_record/templates/create_impressions_table.rb.erb +32 -0
  21. data/lib/generators/impressionist_generator.rb +13 -0
  22. data/lib/generators/mongo_mapper/impressionist_generator.rb +8 -0
  23. data/lib/generators/mongoid/impressionist_generator.rb +8 -0
  24. data/lib/generators/templates/impression.rb.erb +8 -0
  25. data/lib/impressionist/bots.rb +21 -0
  26. data/lib/impressionist/controllers/mongoid/impressionist_controller.rb +10 -0
  27. data/lib/impressionist/counter_cache.rb +76 -0
  28. data/lib/impressionist/engine.rb +45 -0
  29. data/lib/impressionist/is_impressionable.rb +23 -0
  30. data/lib/impressionist/load.rb +11 -0
  31. data/lib/impressionist/models/active_record/impression.rb +14 -0
  32. data/lib/impressionist/models/active_record/impressionist/impressionable.rb +12 -0
  33. data/lib/impressionist/models/mongo_mapper/impression.rb +18 -0
  34. data/lib/impressionist/models/mongo_mapper/impressionist/impressionable.rb +21 -0
  35. data/lib/impressionist/models/mongoid/impression.rb +26 -0
  36. data/lib/impressionist/models/mongoid/impressionist/impressionable.rb +28 -0
  37. data/lib/impressionist/rails_toggle.rb +26 -0
  38. data/lib/impressionist/setup_association.rb +53 -0
  39. data/lib/impressionist/update_counters.rb +77 -0
  40. data/lib/impressionist/version.rb +3 -0
  41. data/lib/impressionist.rb +12 -0
  42. data/logo.png +0 -0
  43. data/spec/controllers/articles_controller_spec.rb +113 -0
  44. data/spec/controllers/dummy_controller_spec.rb +13 -0
  45. data/spec/controllers/impressionist_uniqueness_spec.rb +463 -0
  46. data/spec/controllers/posts_controller_spec.rb +36 -0
  47. data/spec/controllers/widgets_controller_spec.rb +103 -0
  48. data/spec/counter_caching_spec.rb +49 -0
  49. data/spec/dummy/.ruby-version +1 -0
  50. data/spec/dummy/Rakefile +6 -0
  51. data/spec/dummy/app/assets/config/manifest.js +1 -0
  52. data/spec/dummy/app/assets/images/.keep +0 -0
  53. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  54. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  55. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  56. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  57. data/spec/dummy/app/controllers/articles_controller.rb +22 -0
  58. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  59. data/spec/dummy/app/controllers/dummy_controller.rb +6 -0
  60. data/spec/dummy/app/controllers/posts_controller.rb +23 -0
  61. data/spec/dummy/app/controllers/profiles_controller.rb +14 -0
  62. data/spec/dummy/app/controllers/widgets_controller.rb +12 -0
  63. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  64. data/spec/dummy/app/javascript/packs/application.js +15 -0
  65. data/spec/dummy/app/jobs/application_job.rb +7 -0
  66. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  67. data/spec/dummy/app/models/application_record.rb +3 -0
  68. data/spec/dummy/app/models/article.rb +3 -0
  69. data/spec/dummy/app/models/concerns/.keep +0 -0
  70. data/spec/dummy/app/models/dummy.rb +7 -0
  71. data/spec/dummy/app/models/post.rb +3 -0
  72. data/spec/dummy/app/models/profile.rb +6 -0
  73. data/spec/dummy/app/models/user.rb +3 -0
  74. data/spec/dummy/app/models/widget.rb +3 -0
  75. data/spec/dummy/app/views/articles/index.html.erb +1 -0
  76. data/spec/dummy/app/views/articles/show.html.erb +1 -0
  77. data/spec/dummy/app/views/dummy/index.html.erb +0 -0
  78. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  79. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  80. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  81. data/spec/dummy/app/views/posts/edit.html.erb +0 -0
  82. data/spec/dummy/app/views/posts/index.html.erb +0 -0
  83. data/spec/dummy/app/views/posts/show.html.erb +0 -0
  84. data/spec/dummy/app/views/profiles/show.html.erb +3 -0
  85. data/spec/dummy/app/views/widgets/index.html.erb +0 -0
  86. data/spec/dummy/app/views/widgets/new.html.erb +0 -0
  87. data/spec/dummy/app/views/widgets/show.html.erb +0 -0
  88. data/spec/dummy/bin/rails +4 -0
  89. data/spec/dummy/bin/rake +4 -0
  90. data/spec/dummy/bin/setup +33 -0
  91. data/spec/dummy/config/application.rb +20 -0
  92. data/spec/dummy/config/boot.rb +5 -0
  93. data/spec/dummy/config/cable.yml +10 -0
  94. data/spec/dummy/config/database.yml +25 -0
  95. data/spec/dummy/config/environment.rb +5 -0
  96. data/spec/dummy/config/environments/development.rb +62 -0
  97. data/spec/dummy/config/environments/production.rb +112 -0
  98. data/spec/dummy/config/environments/test.rb +49 -0
  99. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  100. data/spec/dummy/config/initializers/assets.rb +12 -0
  101. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  102. data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
  103. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  104. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  105. data/spec/dummy/config/initializers/impression.rb +8 -0
  106. data/spec/dummy/config/initializers/inflections.rb +16 -0
  107. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  108. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  109. data/spec/dummy/config/locales/en.yml +33 -0
  110. data/spec/dummy/config/puma.rb +38 -0
  111. data/spec/dummy/config/routes.rb +4 -0
  112. data/spec/dummy/config/spring.rb +6 -0
  113. data/spec/dummy/config/storage.yml +34 -0
  114. data/spec/dummy/config.ru +5 -0
  115. data/spec/dummy/config.ru2 +4 -0
  116. data/spec/dummy/db/development.sqlite3 +0 -0
  117. data/spec/dummy/db/migrate/20110201153144_create_articles.rb +13 -0
  118. data/spec/dummy/db/migrate/20110210205028_create_posts.rb +13 -0
  119. data/spec/dummy/db/migrate/20111127184039_create_widgets.rb +15 -0
  120. data/spec/dummy/db/migrate/20150207135825_create_profiles.rb +10 -0
  121. data/spec/dummy/db/migrate/20150207140310_create_friendly_id_slugs.rb +18 -0
  122. data/spec/dummy/db/migrate/20200720143817_create_impressions_table.rb +32 -0
  123. data/spec/dummy/db/schema.rb +77 -0
  124. data/spec/dummy/lib/assets/.keep +0 -0
  125. data/spec/dummy/log/.keep +0 -0
  126. data/spec/dummy/log/development.log +129 -0
  127. data/spec/dummy/public/404.html +67 -0
  128. data/spec/dummy/public/422.html +67 -0
  129. data/spec/dummy/public/500.html +66 -0
  130. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  131. data/spec/dummy/public/apple-touch-icon.png +0 -0
  132. data/spec/dummy/public/favicon.ico +0 -0
  133. data/spec/dummy/storage/.keep +0 -0
  134. data/spec/fixtures/articles.yml +3 -0
  135. data/spec/fixtures/impressions.yml +43 -0
  136. data/spec/fixtures/posts.yml +3 -0
  137. data/spec/fixtures/profiles.yml +4 -0
  138. data/spec/fixtures/widgets.yml +4 -0
  139. data/spec/initializers_spec.rb +21 -0
  140. data/spec/models/bots_spec.rb +25 -0
  141. data/spec/models/impression_spec.rb +66 -0
  142. data/spec/rails_generators/rails_generators_spec.rb +23 -0
  143. data/spec/rails_helper.rb +11 -0
  144. data/spec/rails_toggle_spec.rb +31 -0
  145. data/spec/setup_association_spec.rb +48 -0
  146. data/spec/spec_helper.rb +43 -0
  147. data/upgrade_migrations/version_0_3_0.rb +27 -0
  148. data/upgrade_migrations/version_0_4_0.rb +9 -0
  149. data/upgrade_migrations/version_1_5_2.rb +12 -0
  150. metadata +302 -0
@@ -0,0 +1,129 @@
1
+  (1.0ms) SELECT sqlite_version(*)
2
+  (1.4ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)
3
+  (0.9ms) CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL)
4
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
5
+ Migrating to CreateArticles (20110201153144)
6
+  (0.0ms) begin transaction
7
+  (0.3ms) CREATE TABLE "articles" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime, "updated_at" datetime)
8
+ primary::SchemaMigration Create (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20110201153144"]]
9
+  (0.6ms) commit transaction
10
+ Migrating to CreatePosts (20110210205028)
11
+  (0.0ms) begin transaction
12
+  (0.3ms) CREATE TABLE "posts" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime, "updated_at" datetime)
13
+ primary::SchemaMigration Create (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20110210205028"]]
14
+  (0.6ms) commit transaction
15
+ Migrating to CreateWidgets (20111127184039)
16
+  (0.0ms) begin transaction
17
+  (0.3ms) CREATE TABLE "widgets" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "impressions_count" integer DEFAULT 0, "created_at" datetime, "updated_at" datetime)
18
+ primary::SchemaMigration Create (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20111127184039"]]
19
+  (0.7ms) commit transaction
20
+ Migrating to CreateImpressionsTable (20130719024021)
21
+  (0.0ms) begin transaction
22
+  (0.1ms) DROP TABLE IF EXISTS "impressions"
23
+  (0.3ms) CREATE TABLE "impressions" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "impressionable_type" varchar, "impressionable_id" integer, "user_id" integer, "controller_name" varchar, "action_name" varchar, "view_name" varchar, "request_hash" varchar, "ip_address" varchar, "session_hash" varchar, "message" text, "params" text, "referrer" text, "created_at" datetime, "updated_at" datetime)
24
+  (0.1ms) CREATE INDEX "impressionable_type_message_index" ON "impressions" ("impressionable_type", "message", "impressionable_id")
25
+  (0.1ms) CREATE INDEX "poly_request_index" ON "impressions" ("impressionable_type", "impressionable_id", "request_hash")
26
+  (0.1ms) CREATE INDEX "poly_ip_index" ON "impressions" ("impressionable_type", "impressionable_id", "ip_address")
27
+  (0.1ms) CREATE INDEX "poly_session_index" ON "impressions" ("impressionable_type", "impressionable_id", "session_hash")
28
+  (0.1ms) CREATE INDEX "controlleraction_request_index" ON "impressions" ("controller_name", "action_name", "request_hash")
29
+  (0.1ms) CREATE INDEX "controlleraction_ip_index" ON "impressions" ("controller_name", "action_name", "ip_address")
30
+  (0.1ms) CREATE INDEX "controlleraction_session_index" ON "impressions" ("controller_name", "action_name", "session_hash")
31
+  (0.1ms) CREATE INDEX "poly_params_request_index" ON "impressions" ("impressionable_type", "impressionable_id", "params")
32
+  (0.1ms) CREATE INDEX "index_impressions_on_user_id" ON "impressions" ("user_id")
33
+ primary::SchemaMigration Create (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20130719024021"]]
34
+  (0.8ms) commit transaction
35
+ Migrating to CreateProfiles (20150207135825)
36
+  (0.0ms) begin transaction
37
+  (0.3ms) CREATE TABLE "profiles" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar, "slug" varchar, "created_at" datetime, "updated_at" datetime)
38
+ primary::SchemaMigration Create (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20150207135825"]]
39
+  (0.8ms) commit transaction
40
+ Migrating to CreateFriendlyIdSlugs (20150207140310)
41
+  (0.0ms) begin transaction
42
+  (0.3ms) CREATE TABLE "friendly_id_slugs" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "slug" varchar NOT NULL, "sluggable_id" integer NOT NULL, "sluggable_type" varchar(40), "created_at" datetime)
43
+  (0.1ms) CREATE INDEX "index_friendly_id_slugs_on_sluggable_id" ON "friendly_id_slugs" ("sluggable_id")
44
+  (0.1ms) CREATE UNIQUE INDEX "index_friendly_id_slugs_on_slug_and_sluggable_type" ON "friendly_id_slugs" ("slug", "sluggable_type")
45
+  (0.1ms) CREATE INDEX "index_friendly_id_slugs_on_sluggable_type" ON "friendly_id_slugs" ("sluggable_type")
46
+ primary::SchemaMigration Create (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20150207140310"]]
47
+  (0.7ms) commit transaction
48
+ ActiveRecord::InternalMetadata Load (0.1ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]]
49
+  (0.0ms) begin transaction
50
+ ActiveRecord::InternalMetadata Create (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["key", "environment"], ["value", "development"], ["created_at", "2020-04-25 21:53:31.789246"], ["updated_at", "2020-04-25 21:53:31.789246"]]
51
+  (0.5ms) commit transaction
52
+  (0.1ms) SELECT sqlite_version(*)
53
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
54
+  (1.0ms) SELECT sqlite_version(*)
55
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
56
+ ActiveRecord::InternalMetadata Load (0.1ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]]
57
+  (0.0ms) SELECT sqlite_version(*)
58
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
59
+  (1.7ms) SELECT sqlite_version(*)
60
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
61
+ ActiveRecord::InternalMetadata Load (0.1ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]]
62
+  (0.0ms) SELECT sqlite_version(*)
63
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
64
+  (1.1ms) SELECT sqlite_version(*)
65
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
66
+ ActiveRecord::InternalMetadata Load (0.1ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]]
67
+  (0.0ms) SELECT sqlite_version(*)
68
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
69
+  (2.0ms) SELECT sqlite_version(*)
70
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
71
+ ActiveRecord::InternalMetadata Load (0.1ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]]
72
+  (0.0ms) SELECT sqlite_version(*)
73
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
74
+  (2.0ms) SELECT sqlite_version(*)
75
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
76
+  (0.1ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? [["key", "environment"]]
77
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
78
+  (0.1ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? [["key", "environment"]]
79
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
80
+  (0.1ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? [["key", "environment"]]
81
+  (0.0ms) SELECT sqlite_version(*)
82
+  (0.0ms) SELECT sqlite_version(*)
83
+  (0.1ms) DROP TABLE IF EXISTS "articles"
84
+  (1.3ms) CREATE TABLE "articles" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime, "updated_at" datetime)
85
+  (0.1ms) DROP TABLE IF EXISTS "friendly_id_slugs"
86
+  (0.9ms) CREATE TABLE "friendly_id_slugs" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "slug" varchar NOT NULL, "sluggable_id" integer NOT NULL, "sluggable_type" varchar(40), "created_at" datetime)
87
+  (1.1ms) CREATE UNIQUE INDEX "index_friendly_id_slugs_on_slug_and_sluggable_type" ON "friendly_id_slugs" ("slug", "sluggable_type")
88
+  (0.8ms) CREATE INDEX "index_friendly_id_slugs_on_sluggable_id" ON "friendly_id_slugs" ("sluggable_id")
89
+  (0.9ms) CREATE INDEX "index_friendly_id_slugs_on_sluggable_type" ON "friendly_id_slugs" ("sluggable_type")
90
+  (0.1ms) DROP TABLE IF EXISTS "impressions"
91
+  (0.9ms) CREATE TABLE "impressions" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "impressionable_type" varchar, "impressionable_id" integer, "user_id" integer, "controller_name" varchar, "action_name" varchar, "view_name" varchar, "request_hash" varchar, "ip_address" varchar, "session_hash" varchar, "message" text, "params" text, "referrer" text, "created_at" datetime, "updated_at" datetime)
92
+  (0.8ms) CREATE INDEX "controlleraction_ip_index" ON "impressions" ("controller_name", "action_name", "ip_address")
93
+  (0.8ms) CREATE INDEX "controlleraction_request_index" ON "impressions" ("controller_name", "action_name", "request_hash")
94
+  (0.8ms) CREATE INDEX "controlleraction_session_index" ON "impressions" ("controller_name", "action_name", "session_hash")
95
+  (0.8ms) CREATE INDEX "poly_ip_index" ON "impressions" ("impressionable_type", "impressionable_id", "ip_address")
96
+  (1.0ms) CREATE INDEX "poly_params_request_index" ON "impressions" ("impressionable_type", "impressionable_id", "params")
97
+  (1.0ms) CREATE INDEX "poly_request_index" ON "impressions" ("impressionable_type", "impressionable_id", "request_hash")
98
+  (0.9ms) CREATE INDEX "poly_session_index" ON "impressions" ("impressionable_type", "impressionable_id", "session_hash")
99
+  (1.0ms) CREATE INDEX "impressionable_type_message_index" ON "impressions" ("impressionable_type", "message", "impressionable_id")
100
+  (0.9ms) CREATE INDEX "index_impressions_on_user_id" ON "impressions" ("user_id")
101
+  (0.1ms) DROP TABLE IF EXISTS "posts"
102
+  (0.9ms) CREATE TABLE "posts" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime, "updated_at" datetime)
103
+  (0.2ms) DROP TABLE IF EXISTS "profiles"
104
+  (0.9ms) CREATE TABLE "profiles" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar, "slug" varchar, "created_at" datetime, "updated_at" datetime)
105
+  (0.1ms) DROP TABLE IF EXISTS "widgets"
106
+  (0.9ms) CREATE TABLE "widgets" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "impressions_count" integer DEFAULT 0, "created_at" datetime, "updated_at" datetime)
107
+  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)
108
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
109
+  (1.0ms) INSERT INTO "schema_migrations" (version) VALUES (20150207140310)
110
+  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES
111
+ (20110201153144),
112
+ (20110210205028),
113
+ (20111127184039),
114
+ (20150207135825);
115
+
116
+ 
117
+  (1.1ms) CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL)
118
+ ActiveRecord::InternalMetadata Load (0.2ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]]
119
+  (0.0ms) begin transaction
120
+ ActiveRecord::InternalMetadata Create (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["key", "environment"], ["value", "development"], ["created_at", "2020-04-25 22:37:24.495207"], ["updated_at", "2020-04-25 22:37:24.495207"]]
121
+  (0.6ms) commit transaction
122
+ ActiveRecord::InternalMetadata Load (0.1ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]]
123
+  (0.0ms) begin transaction
124
+ ActiveRecord::InternalMetadata Update (0.3ms) UPDATE "ar_internal_metadata" SET "value" = ?, "updated_at" = ? WHERE "ar_internal_metadata"."key" = ? [["value", "test"], ["updated_at", "2020-04-25 22:37:24.500047"], ["key", "environment"]]
125
+  (0.5ms) commit transaction
126
+ ActiveRecord::InternalMetadata Load (0.1ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "schema_sha1"], ["LIMIT", 1]]
127
+  (0.0ms) begin transaction
128
+ ActiveRecord::InternalMetadata Create (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["key", "schema_sha1"], ["value", "5ae040660cab75fdb1eb4d29b60ed71248910310"], ["created_at", "2020-04-25 22:37:24.504240"], ["updated_at", "2020-04-25 22:37:24.504240"]]
129
+  (0.7ms) commit transaction
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
File without changes
File without changes
@@ -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,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Impressionist do
4
+ let(:imp) { RUBY_VERSION.match("1.8") ? "is_impressionable" : :is_impressionable }
5
+
6
+ it "is extended from ActiveRecord::Base" do
7
+ expect(ActiveRecord::Base).to respond_to(imp)
8
+ # ActiveRecord::Base.methods.include?(method).should be_truthy
9
+ end
10
+
11
+ it "includes 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 "includes the before_action method in ApplicationController" do
17
+ filters = ApplicationController._process_action_callbacks.select { |c| c.kind == :before }
18
+
19
+ expect(filters.collect(&:filter)).to include(:impressionist_app_filter)
20
+ end
21
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ require './app/models/impressionist/bots'
4
+
5
+ describe Impressionist::Bots do
6
+ describe "bot detection" do
7
+ it "matches wild card" do
8
+ expect(described_class).to be_bot("google.com bot")
9
+ end
10
+
11
+ it "matches a bot list" do
12
+ expect(described_class).to be_bot("A-Online Search")
13
+ end
14
+
15
+ it "skips blank user agents" do
16
+ expect(described_class).not_to be_bot
17
+ expect(described_class).not_to be_bot("")
18
+ expect(described_class).not_to be_bot(nil)
19
+ end
20
+
21
+ it "skips safe matches" do
22
+ expect(described_class).not_to be_bot('127.0.0.1')
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe Impression do
4
+ fixtures :articles, :impressions, :posts, :profiles
5
+
6
+ let(:article) { Article.find(1) }
7
+
8
+ it "saves a blank impression for an Article that has 10 impressions" do
9
+ article.impressions.create
10
+ expect(article.impressions.size).to eq 12
11
+ end
12
+
13
+ it "saves an impression with a message" do
14
+ article.impressions.create(:message => "test message")
15
+ expect(article.impressions.last.message).to eq "test message"
16
+ end
17
+
18
+ it "returns the impression count for the message specified" do
19
+ article.impressions.create(:message => "pageview")
20
+ article.impressions.create(:message => "pageview")
21
+ article.impressions.create(:message => "visit")
22
+
23
+ expect(article.impressionist_count(:message => "pageview", :filter => :all)).to eq 2
24
+ end
25
+
26
+ it "returns the impression count for all with no date range specified" do
27
+ expect(article.impressionist_count(:filter => :all)).to eq 11
28
+ end
29
+
30
+ it "returns unique impression count with no date range specified" do
31
+ expect(article.impressionist_count).to eq 9
32
+ end
33
+
34
+ it "returns impression count with only start date specified" do
35
+ expect(article.impressionist_count(:start_date => "2011-01-01", :filter => :all)).to eq 8
36
+ end
37
+
38
+ it "returns impression count with whole date range specified" do
39
+ expect(article.impressionist_count(:start_date => "2011-01-01", :end_date => "2011-01-02", :filter => :all)).to eq 7
40
+ end
41
+
42
+ it "returns unique impression count with only start date specified" do
43
+ expect(article.impressionist_count(:start_date => "2011-01-01")).to eq 7
44
+ end
45
+
46
+ it "returns unique impression count with date range specified" do
47
+ expect(article.impressionist_count(:start_date => "2011-01-01", :end_date => "2011-01-02")).to eq 7
48
+ end
49
+
50
+ it "returns unique impression count using ip address (which in turn eliminates duplicate request_hashes)" do
51
+ expect(article.impressionist_count(:filter => :ip_address)).to eq 8
52
+ end
53
+
54
+ it "returns unique impression count using session_hash (which in turn eliminates duplicate request_hashes)" do
55
+ expect(article.impressionist_count(:filter => :session_hash)).to eq 7
56
+ end
57
+
58
+ it "deletes impressions on deletion of impressionable" do
59
+ article = Article.create
60
+ impression = article.impressions.create
61
+ article.destroy
62
+
63
+ expect(article).to be_destroyed
64
+ expect(described_class).not_to exist(impression.id)
65
+ end
66
+ 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 "deletes existing migration and generate the migration file" do
9
+ pending
10
+ migrations_dir = Rails.root.join('db/migrate')
11
+ impressions_migration = Dir.entries(migrations_dir).grep(/impressions/)[0]
12
+ File.delete("#{migrations_dir}/#{impressions_migration}") if impressions_migration.present?
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_truthy
16
+ end
17
+
18
+ it "runs 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_truthy
22
+ end
23
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ ENV['RAILS_ENV'] ||= 'test'
4
+
5
+ require 'rails/all'
6
+ require 'rspec/rails'
7
+
8
+ require File.expand_path('./test_app/config/environment', __dir__)
9
+
10
+ RSpec.configure do |config|
11
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'impressionist/rails_toggle'
5
+
6
+ describe Impressionist::RailsToggle do
7
+ let(:toggle) { described_class.new }
8
+
9
+ context 'when using rails < 4' do
10
+ it 'will be included' do
11
+ stub_const('::Rails::VERSION::MAJOR', 3)
12
+
13
+ expect(toggle).to be_should_include
14
+ end
15
+
16
+ it 'will not be included when strong parameters is defined' do
17
+ stub_const('::Rails::VERSION::MAJOR', 3)
18
+ stub_const('StrongParameters', Module.new)
19
+
20
+ expect(toggle).not_to be_should_include
21
+ end
22
+ end
23
+
24
+ context 'when using rails >= 4' do
25
+ it 'will not be included' do
26
+ stub_const('::Rails::VERSION::MAJOR', 4)
27
+
28
+ expect(toggle).not_to be_should_include
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: false
2
+
3
+ require 'spec_helper'
4
+ require 'impressionist/setup_association'
5
+ require 'impressionist/rails_toggle'
6
+
7
+ describe Impressionist::SetupAssociation do
8
+ let(:mock) { double }
9
+ let(:setup_association) { described_class.new(mock) }
10
+
11
+ it 'will include when togglable' do
12
+ allow(mock).to receive(:attr_accessible).and_return(true)
13
+ allow(setup_association).to receive(:toggle).and_return(true)
14
+
15
+ expect(setup_association).to be_include_attr_acc
16
+ end
17
+
18
+ it 'will not include if it is not togglable' do
19
+ allow(setup_association).to receive(:toggle).and_return(false)
20
+ expect(setup_association).not_to be_include_attr_acc
21
+ end
22
+
23
+ context 'when using rails >= 5' do
24
+ it 'sets belongs_to' do
25
+ stub_const('::Rails::VERSION::MAJOR', 5)
26
+
27
+ expect(mock).to receive(:belongs_to).twice.with(
28
+ :impressionable, { polymorphic: true, optional: true }
29
+ ).and_return(true)
30
+
31
+ expect(setup_association.define_belongs_to).to be_truthy
32
+ expect(setup_association.set).to be_falsy
33
+ end
34
+ end
35
+
36
+ context 'when using rails < 5' do
37
+ it 'sets belongs_to' do
38
+ stub_const('::Rails::VERSION::MAJOR', 4)
39
+
40
+ expect(mock).to receive(:belongs_to).twice.with(
41
+ :impressionable, { polymorphic: true }
42
+ ).and_return(true)
43
+
44
+ expect(setup_association.define_belongs_to).to be_truthy
45
+ expect(setup_association.set).to be_falsy
46
+ end
47
+ end
48
+ end