impressionist-cody 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/main.yml +25 -0
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/.rubocop.yml +27 -0
- data/.rubocop_todo.yml +660 -0
- data/CHANGELOG.rdoc +96 -0
- data/Gemfile +22 -0
- data/LICENSE.txt +20 -0
- data/README.md +265 -0
- data/Rakefile +20 -0
- data/UPGRADE_GUIDE.md +13 -0
- data/app/assets/config/manifest.js +3 -0
- data/app/controllers/impressionist_controller.rb +166 -0
- data/app/models/impression.rb +2 -0
- data/app/models/impressionist/bots.rb +1468 -0
- data/app/models/impressionist/impressionable.rb +62 -0
- data/impressionist.gemspec +30 -0
- data/lib/generators/active_record/impressionist_generator.rb +22 -0
- data/lib/generators/active_record/templates/create_impressions_table.rb.erb +32 -0
- data/lib/generators/impressionist_generator.rb +13 -0
- data/lib/generators/mongo_mapper/impressionist_generator.rb +8 -0
- data/lib/generators/mongoid/impressionist_generator.rb +8 -0
- data/lib/generators/templates/impression.rb.erb +8 -0
- data/lib/impressionist/bots.rb +21 -0
- data/lib/impressionist/controllers/mongoid/impressionist_controller.rb +10 -0
- data/lib/impressionist/counter_cache.rb +76 -0
- data/lib/impressionist/engine.rb +45 -0
- data/lib/impressionist/is_impressionable.rb +23 -0
- data/lib/impressionist/load.rb +11 -0
- data/lib/impressionist/models/active_record/impression.rb +14 -0
- data/lib/impressionist/models/active_record/impressionist/impressionable.rb +12 -0
- data/lib/impressionist/models/mongo_mapper/impression.rb +18 -0
- data/lib/impressionist/models/mongo_mapper/impressionist/impressionable.rb +21 -0
- data/lib/impressionist/models/mongoid/impression.rb +26 -0
- data/lib/impressionist/models/mongoid/impressionist/impressionable.rb +28 -0
- data/lib/impressionist/rails_toggle.rb +26 -0
- data/lib/impressionist/setup_association.rb +53 -0
- data/lib/impressionist/update_counters.rb +77 -0
- data/lib/impressionist/version.rb +3 -0
- data/lib/impressionist.rb +12 -0
- data/logo.png +0 -0
- data/spec/controllers/articles_controller_spec.rb +113 -0
- data/spec/controllers/dummy_controller_spec.rb +13 -0
- data/spec/controllers/impressionist_uniqueness_spec.rb +463 -0
- data/spec/controllers/posts_controller_spec.rb +36 -0
- data/spec/controllers/widgets_controller_spec.rb +103 -0
- data/spec/counter_caching_spec.rb +49 -0
- data/spec/dummy/.ruby-version +1 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +1 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/controllers/articles_controller.rb +22 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/controllers/dummy_controller.rb +6 -0
- data/spec/dummy/app/controllers/posts_controller.rb +23 -0
- data/spec/dummy/app/controllers/profiles_controller.rb +14 -0
- data/spec/dummy/app/controllers/widgets_controller.rb +12 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/javascript/packs/application.js +15 -0
- data/spec/dummy/app/jobs/application_job.rb +7 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/article.rb +3 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/dummy.rb +7 -0
- data/spec/dummy/app/models/post.rb +3 -0
- data/spec/dummy/app/models/profile.rb +6 -0
- data/spec/dummy/app/models/user.rb +3 -0
- data/spec/dummy/app/models/widget.rb +3 -0
- data/spec/dummy/app/views/articles/index.html.erb +1 -0
- data/spec/dummy/app/views/articles/show.html.erb +1 -0
- data/spec/dummy/app/views/dummy/index.html.erb +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/app/views/posts/edit.html.erb +0 -0
- data/spec/dummy/app/views/posts/index.html.erb +0 -0
- data/spec/dummy/app/views/posts/show.html.erb +0 -0
- data/spec/dummy/app/views/profiles/show.html.erb +3 -0
- data/spec/dummy/app/views/widgets/index.html.erb +0 -0
- data/spec/dummy/app/views/widgets/new.html.erb +0 -0
- data/spec/dummy/app/views/widgets/show.html.erb +0 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +33 -0
- data/spec/dummy/config/application.rb +20 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +62 -0
- data/spec/dummy/config/environments/production.rb +112 -0
- data/spec/dummy/config/environments/test.rb +49 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +12 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/impression.rb +8 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +38 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/config.ru2 +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20110201153144_create_articles.rb +13 -0
- data/spec/dummy/db/migrate/20110210205028_create_posts.rb +13 -0
- data/spec/dummy/db/migrate/20111127184039_create_widgets.rb +15 -0
- data/spec/dummy/db/migrate/20150207135825_create_profiles.rb +10 -0
- data/spec/dummy/db/migrate/20150207140310_create_friendly_id_slugs.rb +18 -0
- data/spec/dummy/db/migrate/20200720143817_create_impressions_table.rb +32 -0
- data/spec/dummy/db/schema.rb +77 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/log/development.log +129 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/storage/.keep +0 -0
- data/spec/fixtures/articles.yml +3 -0
- data/spec/fixtures/impressions.yml +43 -0
- data/spec/fixtures/posts.yml +3 -0
- data/spec/fixtures/profiles.yml +4 -0
- data/spec/fixtures/widgets.yml +4 -0
- data/spec/initializers_spec.rb +21 -0
- data/spec/models/bots_spec.rb +25 -0
- data/spec/models/impression_spec.rb +66 -0
- data/spec/rails_generators/rails_generators_spec.rb +23 -0
- data/spec/rails_helper.rb +11 -0
- data/spec/rails_toggle_spec.rb +31 -0
- data/spec/setup_association_spec.rb +48 -0
- data/spec/spec_helper.rb +43 -0
- data/upgrade_migrations/version_0_3_0.rb +27 -0
- data/upgrade_migrations/version_0_4_0.rb +9 -0
- data/upgrade_migrations/version_1_5_2.rb +12 -0
- metadata +302 -0
@@ -0,0 +1,129 @@
|
|
1
|
+
[1m[35m (1.0ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
2
|
+
[1m[35m (1.4ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)[0m
|
3
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL)[0m
|
4
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
5
|
+
Migrating to CreateArticles (20110201153144)
|
6
|
+
[1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m
|
7
|
+
[1m[35m (0.3ms)[0m [1m[35mCREATE TABLE "articles" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime, "updated_at" datetime)[0m
|
8
|
+
[1m[36mprimary::SchemaMigration Create (0.1ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES (?)[0m [["version", "20110201153144"]]
|
9
|
+
[1m[35m (0.6ms)[0m [1m[36mcommit transaction[0m
|
10
|
+
Migrating to CreatePosts (20110210205028)
|
11
|
+
[1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m
|
12
|
+
[1m[35m (0.3ms)[0m [1m[35mCREATE TABLE "posts" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime, "updated_at" datetime)[0m
|
13
|
+
[1m[36mprimary::SchemaMigration Create (0.1ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES (?)[0m [["version", "20110210205028"]]
|
14
|
+
[1m[35m (0.6ms)[0m [1m[36mcommit transaction[0m
|
15
|
+
Migrating to CreateWidgets (20111127184039)
|
16
|
+
[1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m
|
17
|
+
[1m[35m (0.3ms)[0m [1m[35mCREATE TABLE "widgets" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "impressions_count" integer DEFAULT 0, "created_at" datetime, "updated_at" datetime)[0m
|
18
|
+
[1m[36mprimary::SchemaMigration Create (0.1ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES (?)[0m [["version", "20111127184039"]]
|
19
|
+
[1m[35m (0.7ms)[0m [1m[36mcommit transaction[0m
|
20
|
+
Migrating to CreateImpressionsTable (20130719024021)
|
21
|
+
[1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m
|
22
|
+
[1m[35m (0.1ms)[0m [1m[35mDROP TABLE IF EXISTS "impressions"[0m
|
23
|
+
[1m[35m (0.3ms)[0m [1m[35mCREATE 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)[0m
|
24
|
+
[1m[35m (0.1ms)[0m [1m[35mCREATE INDEX "impressionable_type_message_index" ON "impressions" ("impressionable_type", "message", "impressionable_id")[0m
|
25
|
+
[1m[35m (0.1ms)[0m [1m[35mCREATE INDEX "poly_request_index" ON "impressions" ("impressionable_type", "impressionable_id", "request_hash")[0m
|
26
|
+
[1m[35m (0.1ms)[0m [1m[35mCREATE INDEX "poly_ip_index" ON "impressions" ("impressionable_type", "impressionable_id", "ip_address")[0m
|
27
|
+
[1m[35m (0.1ms)[0m [1m[35mCREATE INDEX "poly_session_index" ON "impressions" ("impressionable_type", "impressionable_id", "session_hash")[0m
|
28
|
+
[1m[35m (0.1ms)[0m [1m[35mCREATE INDEX "controlleraction_request_index" ON "impressions" ("controller_name", "action_name", "request_hash")[0m
|
29
|
+
[1m[35m (0.1ms)[0m [1m[35mCREATE INDEX "controlleraction_ip_index" ON "impressions" ("controller_name", "action_name", "ip_address")[0m
|
30
|
+
[1m[35m (0.1ms)[0m [1m[35mCREATE INDEX "controlleraction_session_index" ON "impressions" ("controller_name", "action_name", "session_hash")[0m
|
31
|
+
[1m[35m (0.1ms)[0m [1m[35mCREATE INDEX "poly_params_request_index" ON "impressions" ("impressionable_type", "impressionable_id", "params")[0m
|
32
|
+
[1m[35m (0.1ms)[0m [1m[35mCREATE INDEX "index_impressions_on_user_id" ON "impressions" ("user_id")[0m
|
33
|
+
[1m[36mprimary::SchemaMigration Create (0.1ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES (?)[0m [["version", "20130719024021"]]
|
34
|
+
[1m[35m (0.8ms)[0m [1m[36mcommit transaction[0m
|
35
|
+
Migrating to CreateProfiles (20150207135825)
|
36
|
+
[1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m
|
37
|
+
[1m[35m (0.3ms)[0m [1m[35mCREATE TABLE "profiles" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar, "slug" varchar, "created_at" datetime, "updated_at" datetime)[0m
|
38
|
+
[1m[36mprimary::SchemaMigration Create (0.1ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES (?)[0m [["version", "20150207135825"]]
|
39
|
+
[1m[35m (0.8ms)[0m [1m[36mcommit transaction[0m
|
40
|
+
Migrating to CreateFriendlyIdSlugs (20150207140310)
|
41
|
+
[1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m
|
42
|
+
[1m[35m (0.3ms)[0m [1m[35mCREATE 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)[0m
|
43
|
+
[1m[35m (0.1ms)[0m [1m[35mCREATE INDEX "index_friendly_id_slugs_on_sluggable_id" ON "friendly_id_slugs" ("sluggable_id")[0m
|
44
|
+
[1m[35m (0.1ms)[0m [1m[35mCREATE UNIQUE INDEX "index_friendly_id_slugs_on_slug_and_sluggable_type" ON "friendly_id_slugs" ("slug", "sluggable_type")[0m
|
45
|
+
[1m[35m (0.1ms)[0m [1m[35mCREATE INDEX "index_friendly_id_slugs_on_sluggable_type" ON "friendly_id_slugs" ("sluggable_type")[0m
|
46
|
+
[1m[36mprimary::SchemaMigration Create (0.1ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES (?)[0m [["version", "20150207140310"]]
|
47
|
+
[1m[35m (0.7ms)[0m [1m[36mcommit transaction[0m
|
48
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
49
|
+
[1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m
|
50
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.3ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?)[0m [["key", "environment"], ["value", "development"], ["created_at", "2020-04-25 21:53:31.789246"], ["updated_at", "2020-04-25 21:53:31.789246"]]
|
51
|
+
[1m[35m (0.5ms)[0m [1m[36mcommit transaction[0m
|
52
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
53
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
54
|
+
[1m[35m (1.0ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
55
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
56
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
57
|
+
[1m[35m (0.0ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
58
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
59
|
+
[1m[35m (1.7ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
60
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
61
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
62
|
+
[1m[35m (0.0ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
63
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
64
|
+
[1m[35m (1.1ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
65
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
66
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
67
|
+
[1m[35m (0.0ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
68
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
69
|
+
[1m[35m (2.0ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
70
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
71
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
72
|
+
[1m[35m (0.0ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
73
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
74
|
+
[1m[35m (2.0ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
75
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
76
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ?[0m [["key", "environment"]]
|
77
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
78
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ?[0m [["key", "environment"]]
|
79
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
80
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ?[0m [["key", "environment"]]
|
81
|
+
[1m[35m (0.0ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
82
|
+
[1m[35m (0.0ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
83
|
+
[1m[35m (0.1ms)[0m [1m[35mDROP TABLE IF EXISTS "articles"[0m
|
84
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE TABLE "articles" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime, "updated_at" datetime)[0m
|
85
|
+
[1m[35m (0.1ms)[0m [1m[35mDROP TABLE IF EXISTS "friendly_id_slugs"[0m
|
86
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE 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)[0m
|
87
|
+
[1m[35m (1.1ms)[0m [1m[35mCREATE UNIQUE INDEX "index_friendly_id_slugs_on_slug_and_sluggable_type" ON "friendly_id_slugs" ("slug", "sluggable_type")[0m
|
88
|
+
[1m[35m (0.8ms)[0m [1m[35mCREATE INDEX "index_friendly_id_slugs_on_sluggable_id" ON "friendly_id_slugs" ("sluggable_id")[0m
|
89
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE INDEX "index_friendly_id_slugs_on_sluggable_type" ON "friendly_id_slugs" ("sluggable_type")[0m
|
90
|
+
[1m[35m (0.1ms)[0m [1m[35mDROP TABLE IF EXISTS "impressions"[0m
|
91
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE 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)[0m
|
92
|
+
[1m[35m (0.8ms)[0m [1m[35mCREATE INDEX "controlleraction_ip_index" ON "impressions" ("controller_name", "action_name", "ip_address")[0m
|
93
|
+
[1m[35m (0.8ms)[0m [1m[35mCREATE INDEX "controlleraction_request_index" ON "impressions" ("controller_name", "action_name", "request_hash")[0m
|
94
|
+
[1m[35m (0.8ms)[0m [1m[35mCREATE INDEX "controlleraction_session_index" ON "impressions" ("controller_name", "action_name", "session_hash")[0m
|
95
|
+
[1m[35m (0.8ms)[0m [1m[35mCREATE INDEX "poly_ip_index" ON "impressions" ("impressionable_type", "impressionable_id", "ip_address")[0m
|
96
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE INDEX "poly_params_request_index" ON "impressions" ("impressionable_type", "impressionable_id", "params")[0m
|
97
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE INDEX "poly_request_index" ON "impressions" ("impressionable_type", "impressionable_id", "request_hash")[0m
|
98
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE INDEX "poly_session_index" ON "impressions" ("impressionable_type", "impressionable_id", "session_hash")[0m
|
99
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE INDEX "impressionable_type_message_index" ON "impressions" ("impressionable_type", "message", "impressionable_id")[0m
|
100
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE INDEX "index_impressions_on_user_id" ON "impressions" ("user_id")[0m
|
101
|
+
[1m[35m (0.1ms)[0m [1m[35mDROP TABLE IF EXISTS "posts"[0m
|
102
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE TABLE "posts" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime, "updated_at" datetime)[0m
|
103
|
+
[1m[35m (0.2ms)[0m [1m[35mDROP TABLE IF EXISTS "profiles"[0m
|
104
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE TABLE "profiles" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar, "slug" varchar, "created_at" datetime, "updated_at" datetime)[0m
|
105
|
+
[1m[35m (0.1ms)[0m [1m[35mDROP TABLE IF EXISTS "widgets"[0m
|
106
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE TABLE "widgets" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "impressions_count" integer DEFAULT 0, "created_at" datetime, "updated_at" datetime)[0m
|
107
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)[0m
|
108
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
109
|
+
[1m[35m (1.0ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES (20150207140310)[0m
|
110
|
+
[1m[35m (0.9ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES
|
111
|
+
(20110201153144),
|
112
|
+
(20110210205028),
|
113
|
+
(20111127184039),
|
114
|
+
(20150207135825);
|
115
|
+
|
116
|
+
[0m
|
117
|
+
[1m[35m (1.1ms)[0m [1m[35mCREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL)[0m
|
118
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.2ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
119
|
+
[1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m
|
120
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.3ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?)[0m [["key", "environment"], ["value", "development"], ["created_at", "2020-04-25 22:37:24.495207"], ["updated_at", "2020-04-25 22:37:24.495207"]]
|
121
|
+
[1m[35m (0.6ms)[0m [1m[36mcommit transaction[0m
|
122
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
123
|
+
[1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m
|
124
|
+
[1m[36mActiveRecord::InternalMetadata Update (0.3ms)[0m [1m[33mUPDATE "ar_internal_metadata" SET "value" = ?, "updated_at" = ? WHERE "ar_internal_metadata"."key" = ?[0m [["value", "test"], ["updated_at", "2020-04-25 22:37:24.500047"], ["key", "environment"]]
|
125
|
+
[1m[35m (0.5ms)[0m [1m[36mcommit transaction[0m
|
126
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "schema_sha1"], ["LIMIT", 1]]
|
127
|
+
[1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m
|
128
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.3ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?)[0m [["key", "schema_sha1"], ["value", "5ae040660cab75fdb1eb4d29b60ed71248910310"], ["created_at", "2020-04-25 22:37:24.504240"], ["updated_at", "2020-04-25 22:37:24.504240"]]
|
129
|
+
[1m[35m (0.7ms)[0m [1m[36mcommit transaction[0m
|
@@ -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
|
File without changes
|
@@ -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,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,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
|