cmor_galleries 0.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +44 -0
  4. data/Rakefile +19 -0
  5. data/app/assets/config/cmor_galleries_manifest.js +2 -0
  6. data/app/assets/javascripts/cmor/galleries/application/keep.js +0 -0
  7. data/app/assets/javascripts/cmor/galleries/application.js +14 -0
  8. data/app/assets/stylesheets/cmor/galleries/application/keep.css +0 -0
  9. data/app/assets/stylesheets/cmor/galleries/application.css +15 -0
  10. data/app/controllers/cmor/galleries/application_controller.rb +5 -0
  11. data/app/controllers/cmor/galleries/application_resources_controller.rb +11 -0
  12. data/app/controllers/cmor/galleries/picture_galleries_controller.rb +17 -0
  13. data/app/models/cmor/galleries/application_record.rb +5 -0
  14. data/app/models/cmor/galleries/picture_detail.rb +26 -0
  15. data/app/models/cmor/galleries/picture_gallery.rb +88 -0
  16. data/app/view_helpers/cmor/galleries/galleries_helper.rb +34 -0
  17. data/app/view_helpers/cmor/galleries/pictures_helper.rb +37 -0
  18. data/app/views/cmor/galleries/galleries_helper/_render.html.haml +17 -0
  19. data/app/views/cmor/galleries/picture_galleries/index.html.haml +16 -0
  20. data/app/views/cmor/galleries/picture_galleries/show.html.haml +18 -0
  21. data/app/views/cmor/galleries/pictures_helper/_render.html.haml +15 -0
  22. data/app/views/layouts/cmor/galleries/application.html.erb +14 -0
  23. data/config/initializers/assets.rb +1 -0
  24. data/config/locales/de.yml +48 -0
  25. data/config/locales/en.yml +46 -0
  26. data/config/routes.rb +9 -0
  27. data/db/migrate/20180301153325_create_cmor_galleries_picture_galleries.rb +11 -0
  28. data/db/migrate/20180302082402_create_cmor_galleries_picture_details.rb +14 -0
  29. data/lib/cmor/galleries/configuration.rb +12 -0
  30. data/lib/cmor/galleries/engine.rb +13 -0
  31. data/lib/cmor/galleries/version.rb +7 -0
  32. data/lib/cmor/galleries.rb +10 -0
  33. data/lib/cmor_galleries.rb +7 -0
  34. data/lib/generators/cmor/galleries/install/install_generator.rb +24 -0
  35. data/lib/generators/cmor/galleries/install/templates/initializer.rb +27 -0
  36. data/lib/generators/cmor/galleries/install/templates/routes.source +3 -0
  37. data/lib/tasks/cmor_galleries_tasks.rake +4 -0
  38. data/spec/dummy/config/initializers/cmor_galleries.rb +27 -0
  39. data/spec/dummy/config/initializers/i18n.rb +2 -0
  40. data/spec/dummy/db/development.sqlite3 +0 -0
  41. data/spec/dummy/db/migrate/20190325174835_create_active_storage_tables.active_storage.rb +27 -0
  42. data/spec/dummy/db/migrate/20190325174856_create_cmor_galleries_picture_galleries.cmor_galleries.rb +12 -0
  43. data/spec/dummy/db/migrate/20190325174857_create_cmor_galleries_picture_details.cmor_galleries.rb +15 -0
  44. data/spec/dummy/db/test.sqlite3 +0 -0
  45. data/spec/dummy/log/development.log +122 -0
  46. data/spec/dummy/log/test.log +143 -0
  47. data/spec/dummy/tmp/development_secret.txt +1 -0
  48. data/spec/dummy/tmp/storage/B8/o7/B8o7CDJi1ubYmEcP3ZAGkEiM +0 -0
  49. data/spec/dummy/tmp/storage/Hp/aX/HpaXaXSTTBQhyk9pwjiXNpvs +0 -0
  50. data/spec/factories/cmor_galleries_picture_details.rb +17 -0
  51. data/spec/factories/cmor_galleries_picture_galleries.rb +5 -0
  52. data/spec/files/cmor/galleries/picture_details/example.png +0 -0
  53. data/spec/models/cmor/galleries/picture_detail_spec.rb +7 -0
  54. data/spec/models/cmor/galleries/picture_gallery_spec.rb +8 -0
  55. data/spec/models/generic_spec.rb +50 -0
  56. data/spec/models/i18n_spec.rb +41 -0
  57. data/spec/rails_helper.rb +62 -0
  58. data/spec/rails_helper.rb~ +58 -0
  59. data/spec/spec_helper.rb +96 -0
  60. data/spec/spec_helper.rb~ +96 -0
  61. data/spec/support/capybara.rb +1 -0
  62. data/spec/support/factory_bot.rb +5 -0
  63. data/spec/support/rao-shoulda_matchers.rb +5 -0
  64. data/spec/support/shoulda_matchers.rb +8 -0
  65. data/spec/support~/factory_bot_rails.rb +11 -0
  66. data/spec/support~/shoulda_matchers.rb +8 -0
  67. metadata +430 -0
@@ -0,0 +1,24 @@
1
+ module Cmor::Galleries
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ desc 'Generates the initializer'
5
+
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ attr_reader :base_controller_class_name
9
+
10
+ def initialize(*args)
11
+ super
12
+ @base_controller_class_name = ENV.fetch('BASE_CONTROLLER_CLASS_NAME') { '::ApplicationController' }
13
+ end
14
+
15
+ def generate_initializer
16
+ template 'initializer.rb', 'config/initializers/cmor_galleries.rb'
17
+ end
18
+
19
+ def generate_routes
20
+ route File.read(File.join(File.expand_path('../templates', __FILE__), 'routes.source'))
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,27 @@
1
+ Cmor::Galleries.configure do |config|
2
+ # Set the base controller for the page controller
3
+ #
4
+ # Default: config.base_controller = '<%= base_controller_class_name %>'
5
+ #
6
+ config.base_controller = '<%= base_controller_class_name %>'
7
+
8
+ # These options are the defaults that will be applied to when rendering
9
+ # galleries through the galleries helper.
10
+ #
11
+ # Default: config.galleries_helper_render_default_options = { variant_options: {}, show_details: false }
12
+ #
13
+ config.galleries_helper_render_default_options = { variant_options: {}, show_details: false }
14
+
15
+ # These options are the defaults that will be applied to when rendering
16
+ # pictures through the pictures helper.
17
+ #
18
+ # Default: config.pictures_helper_render_default_options = { image_tag_only: true }
19
+ #
20
+ config.pictures_helper_render_default_options = { image_tag_only: true }
21
+
22
+ # This options will be applied when rendering thumbails in galleries.
23
+ #
24
+ # Default: config.thumbnail_variant_options = { combine_options: { resize: "384x216^", extent: "384x216", gravity: "center" } }
25
+ #
26
+ config.thumbnail_variant_options = { combine_options: { resize: "384x216^", extent: "384x216", gravity: "center" } }
27
+ end
@@ -0,0 +1,3 @@
1
+
2
+
3
+ mount Cmor::Galleries::Engine, at: '/'
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :cmor/galleries do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,27 @@
1
+ Cmor::Galleries.configure do |config|
2
+ # Set the base controller for the page controller
3
+ #
4
+ # Default: config.base_controller = '::ApplicationController'
5
+ #
6
+ config.base_controller = '::ApplicationController'
7
+
8
+ # These options are the defaults that will be applied to when rendering
9
+ # galleries through the galleries helper.
10
+ #
11
+ # Default: config.galleries_helper_render_default_options = { variant_options: {}, show_details: false }
12
+ #
13
+ config.galleries_helper_render_default_options = { variant_options: {}, show_details: false }
14
+
15
+ # These options are the defaults that will be applied to when rendering
16
+ # pictures through the pictures helper.
17
+ #
18
+ # Default: config.pictures_helper_render_default_options = { image_tag_only: true }
19
+ #
20
+ config.pictures_helper_render_default_options = { image_tag_only: true }
21
+
22
+ # This options will be applied when rendering thumbails in galleries.
23
+ #
24
+ # Default: config.thumbnail_variant_options = { combine_options: { resize: "384x216^", extent: "384x216", gravity: "center" } }
25
+ #
26
+ config.thumbnail_variant_options = { combine_options: { resize: "384x216^", extent: "384x216", gravity: "center" } }
27
+ end
@@ -0,0 +1,2 @@
1
+ Rails.application.config.i18n.available_locales = [:en, :de]
2
+ Rails.application.config.i18n.default_locale = :de
Binary file
@@ -0,0 +1,27 @@
1
+ # This migration comes from active_storage (originally 20170806125915)
2
+ class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
3
+ def change
4
+ create_table :active_storage_blobs do |t|
5
+ t.string :key, null: false
6
+ t.string :filename, null: false
7
+ t.string :content_type
8
+ t.text :metadata
9
+ t.bigint :byte_size, null: false
10
+ t.string :checksum, null: false
11
+ t.datetime :created_at, null: false
12
+
13
+ t.index [ :key ], unique: true
14
+ end
15
+
16
+ create_table :active_storage_attachments do |t|
17
+ t.string :name, null: false
18
+ t.references :record, null: false, polymorphic: true, index: false
19
+ t.references :blob, null: false
20
+
21
+ t.datetime :created_at, null: false
22
+
23
+ t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true
24
+ t.foreign_key :active_storage_blobs, column: :blob_id
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,12 @@
1
+ # This migration comes from cmor_galleries (originally 20180301153325)
2
+ class CreateCmorGalleriesPictureGalleries < ActiveRecord::Migration[5.2]
3
+ def change
4
+ create_table :cmor_galleries_picture_galleries do |t|
5
+ t.string :name
6
+ t.timestamp :published_at
7
+ t.text :description
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ # This migration comes from cmor_galleries (originally 20180302082402)
2
+ class CreateCmorGalleriesPictureDetails < ActiveRecord::Migration[5.2]
3
+ def change
4
+ create_table :cmor_galleries_picture_details do |t|
5
+ t.integer :picture_gallery_id
6
+ t.integer :asset_id
7
+ t.string :title
8
+ t.text :description
9
+ t.integer :position
10
+ t.timestamp :published_at
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
Binary file
@@ -0,0 +1,122 @@
1
+  (0.2ms) SELECT sqlite_version(*)
2
+ ↳ bin/rails:4
3
+  (6.6ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)
4
+ ↳ bin/rails:4
5
+  (19.7ms) CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
6
+ ↳ bin/rails:4
7
+  (0.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
8
+ ↳ bin/rails:4
9
+ Migrating to CreateActiveStorageTables (20190325174835)
10
+  (0.2ms) begin transaction
11
+ ↳ bin/rails:4
12
+  (1.0ms) CREATE TABLE "active_storage_blobs" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "key" varchar NOT NULL, "filename" varchar NOT NULL, "content_type" varchar, "metadata" text, "byte_size" bigint NOT NULL, "checksum" varchar NOT NULL, "created_at" datetime NOT NULL)
13
+ ↳ db/migrate/20190325174835_create_active_storage_tables.active_storage.rb:4
14
+  (0.6ms) CREATE UNIQUE INDEX "index_active_storage_blobs_on_key" ON "active_storage_blobs" ("key")
15
+ ↳ db/migrate/20190325174835_create_active_storage_tables.active_storage.rb:4
16
+  (0.4ms) CREATE TABLE "active_storage_attachments" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar NOT NULL, "record_type" varchar NOT NULL, "record_id" integer NOT NULL, "blob_id" integer NOT NULL, "created_at" datetime NOT NULL, CONSTRAINT "fk_rails_c3b3935057"
17
+ FOREIGN KEY ("blob_id")
18
+ REFERENCES "active_storage_blobs" ("id")
19
+ )
20
+ ↳ db/migrate/20190325174835_create_active_storage_tables.active_storage.rb:16
21
+  (0.3ms) CREATE INDEX "index_active_storage_attachments_on_blob_id" ON "active_storage_attachments" ("blob_id")
22
+ ↳ db/migrate/20190325174835_create_active_storage_tables.active_storage.rb:16
23
+  (0.4ms) CREATE UNIQUE INDEX "index_active_storage_attachments_uniqueness" ON "active_storage_attachments" ("record_type", "record_id", "name", "blob_id")
24
+ ↳ db/migrate/20190325174835_create_active_storage_tables.active_storage.rb:16
25
+ ActiveRecord::SchemaMigration Create (0.7ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20190325174835"]]
26
+ ↳ bin/rails:4
27
+  (7.6ms) commit transaction
28
+ ↳ bin/rails:4
29
+ Migrating to CreateCmorGalleriesPictureGalleries (20190325174856)
30
+  (0.4ms) begin transaction
31
+ ↳ bin/rails:4
32
+  (4.1ms) CREATE TABLE "cmor_galleries_picture_galleries" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "published_at" datetime, "description" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
33
+ ↳ db/migrate/20190325174856_create_cmor_galleries_picture_galleries.cmor_galleries.rb:4
34
+ ActiveRecord::SchemaMigration Create (0.7ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20190325174856"]]
35
+ ↳ bin/rails:4
36
+  (27.3ms) commit transaction
37
+ ↳ bin/rails:4
38
+ Migrating to CreateCmorGalleriesPictureDetails (20190325174857)
39
+  (0.2ms) begin transaction
40
+ ↳ bin/rails:4
41
+  (0.5ms) CREATE TABLE "cmor_galleries_picture_details" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "picture_gallery_id" integer, "asset_id" integer, "title" varchar, "description" text, "position" integer, "published_at" datetime, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
42
+ ↳ db/migrate/20190325174857_create_cmor_galleries_picture_details.cmor_galleries.rb:4
43
+ ActiveRecord::SchemaMigration Create (0.6ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20190325174857"]]
44
+ ↳ bin/rails:4
45
+  (6.5ms) commit transaction
46
+ ↳ bin/rails:4
47
+ ActiveRecord::InternalMetadata Load (1.0ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]]
48
+ ↳ bin/rails:4
49
+  (0.4ms) begin transaction
50
+ ↳ bin/rails:4
51
+ ActiveRecord::InternalMetadata Create (1.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["key", "environment"], ["value", "development"], ["created_at", "2019-03-25 17:48:56.609969"], ["updated_at", "2019-03-25 17:48:56.609969"]]
52
+ ↳ bin/rails:4
53
+  (28.1ms) commit transaction
54
+ ↳ bin/rails:4
55
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
56
+ ↳ bin/rails:4
57
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
58
+ ↳ bin/rails:4
59
+  (0.3ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? [["key", "environment"]]
60
+ ↳ bin/rails:4
61
+  (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
62
+ ↳ bin/rails:4
63
+  (0.7ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? [["key", "environment"]]
64
+ ↳ bin/rails:4
65
+  (0.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
66
+ ↳ bin/rails:4
67
+  (0.2ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? [["key", "environment"]]
68
+ ↳ bin/rails:4
69
+  (0.2ms) DROP TABLE IF EXISTS "active_storage_attachments"
70
+ ↳ db/schema.rb:15
71
+  (0.2ms) SELECT sqlite_version(*)
72
+ ↳ db/schema.rb:15
73
+  (6.1ms) CREATE TABLE "active_storage_attachments" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar NOT NULL, "record_type" varchar NOT NULL, "record_id" integer NOT NULL, "blob_id" integer NOT NULL, "created_at" datetime NOT NULL)
74
+ ↳ db/schema.rb:15
75
+  (4.6ms) CREATE INDEX "index_active_storage_attachments_on_blob_id" ON "active_storage_attachments" ("blob_id")
76
+ ↳ db/schema.rb:15
77
+  (5.7ms) CREATE UNIQUE INDEX "index_active_storage_attachments_uniqueness" ON "active_storage_attachments" ("record_type", "record_id", "name", "blob_id")
78
+ ↳ db/schema.rb:15
79
+  (0.3ms) DROP TABLE IF EXISTS "active_storage_blobs"
80
+ ↳ db/schema.rb:25
81
+  (5.7ms) CREATE TABLE "active_storage_blobs" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "key" varchar NOT NULL, "filename" varchar NOT NULL, "content_type" varchar, "metadata" text, "byte_size" bigint NOT NULL, "checksum" varchar NOT NULL, "created_at" datetime NOT NULL)
82
+ ↳ db/schema.rb:25
83
+  (5.2ms) CREATE UNIQUE INDEX "index_active_storage_blobs_on_key" ON "active_storage_blobs" ("key")
84
+ ↳ db/schema.rb:25
85
+  (0.2ms) DROP TABLE IF EXISTS "cmor_galleries_picture_details"
86
+ ↳ db/schema.rb:36
87
+  (4.8ms) CREATE TABLE "cmor_galleries_picture_details" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "picture_gallery_id" integer, "asset_id" integer, "title" varchar, "description" text, "position" integer, "published_at" datetime, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
88
+ ↳ db/schema.rb:36
89
+  (0.2ms) DROP TABLE IF EXISTS "cmor_galleries_picture_galleries"
90
+ ↳ db/schema.rb:47
91
+  (3.7ms) CREATE TABLE "cmor_galleries_picture_galleries" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "published_at" datetime, "description" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
92
+ ↳ db/schema.rb:47
93
+  (4.1ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)
94
+ ↳ db/schema.rb:13
95
+  (0.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
96
+ ↳ db/schema.rb:13
97
+  (3.3ms) INSERT INTO "schema_migrations" (version) VALUES (20190325174857)
98
+ ↳ db/schema.rb:13
99
+  (3.5ms) INSERT INTO "schema_migrations" (version) VALUES
100
+ (20190325174856),
101
+ (20190325174835);
102
+
103
+ 
104
+ ↳ db/schema.rb:13
105
+  (3.5ms) CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
106
+ ↳ db/schema.rb:13
107
+ ActiveRecord::InternalMetadata Load (0.2ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]]
108
+ ↳ db/schema.rb:13
109
+  (0.1ms) begin transaction
110
+ ↳ db/schema.rb:13
111
+ ActiveRecord::InternalMetadata Create (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["key", "environment"], ["value", "development"], ["created_at", "2019-03-25 17:48:56.802055"], ["updated_at", "2019-03-25 17:48:56.802055"]]
112
+ ↳ db/schema.rb:13
113
+  (3.7ms) commit transaction
114
+ ↳ db/schema.rb:13
115
+ ActiveRecord::InternalMetadata Load (0.1ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]]
116
+ ↳ bin/rails:4
117
+  (0.1ms) begin transaction
118
+ ↳ bin/rails:4
119
+ ActiveRecord::InternalMetadata Update (0.4ms) UPDATE "ar_internal_metadata" SET "value" = ?, "updated_at" = ? WHERE "ar_internal_metadata"."key" = ? [["value", "test"], ["updated_at", "2019-03-25 17:48:56.813329"], ["key", "environment"]]
120
+ ↳ bin/rails:4
121
+  (5.0ms) commit transaction
122
+ ↳ bin/rails:4
@@ -0,0 +1,143 @@
1
+  (0.1ms) begin transaction
2
+ Cmor::Galleries::PictureGallery Exists (0.3ms) SELECT 1 AS one FROM "cmor_galleries_picture_galleries" WHERE "cmor_galleries_picture_galleries"."name" IS NULL LIMIT ? [["LIMIT", 1]]
3
+  (0.2ms) rollback transaction
4
+  (0.1ms) begin transaction
5
+ Cmor::Galleries::PictureGallery Load (0.4ms) SELECT "cmor_galleries_picture_galleries".* FROM "cmor_galleries_picture_galleries" ORDER BY "cmor_galleries_picture_galleries"."id" ASC LIMIT ? [["LIMIT", 1]]
6
+  (0.4ms) SAVEPOINT active_record_1
7
+ Cmor::Galleries::PictureGallery Create (2.4ms) INSERT INTO "cmor_galleries_picture_galleries" ("created_at", "updated_at") VALUES (?, ?) [["created_at", "2019-03-25 17:49:04.551608"], ["updated_at", "2019-03-25 17:49:04.551608"]]
8
+  (0.2ms) RELEASE SAVEPOINT active_record_1
9
+  (0.1ms) SAVEPOINT active_record_1
10
+ Cmor::Galleries::PictureGallery Update (2.5ms) UPDATE "cmor_galleries_picture_galleries" SET "name" = ?, "updated_at" = ? WHERE "cmor_galleries_picture_galleries"."id" = ? [["name", "dummy value"], ["updated_at", "2019-03-25 17:49:04.560762"], ["id", 1]]
11
+  (0.2ms) RELEASE SAVEPOINT active_record_1
12
+ Cmor::Galleries::PictureGallery Exists (0.4ms) SELECT 1 AS one FROM "cmor_galleries_picture_galleries" WHERE "cmor_galleries_picture_galleries"."name" = ? LIMIT ? [["name", "dummy value"], ["LIMIT", 1]]
13
+ Cmor::Galleries::PictureGallery Exists (0.3ms) SELECT 1 AS one FROM "cmor_galleries_picture_galleries" WHERE "cmor_galleries_picture_galleries"."name" = ? LIMIT ? [["name", "DUMMY VALUE"], ["LIMIT", 1]]
14
+  (0.2ms) rollback transaction
15
+  (0.1ms) begin transaction
16
+  (0.3ms) rollback transaction
17
+  (0.2ms) begin transaction
18
+  (0.9ms) rollback transaction
19
+  (0.4ms) begin transaction
20
+ Cmor::Galleries::PictureGallery Exists (0.3ms) SELECT 1 AS one FROM "cmor_galleries_picture_galleries" WHERE "cmor_galleries_picture_galleries"."name" = ? LIMIT ? [["name", "Picture Gallery #1"], ["LIMIT", 1]]
21
+  (0.1ms) rollback transaction
22
+  (0.1ms) begin transaction
23
+ Cmor::Galleries::PictureGallery Exists (0.3ms) SELECT 1 AS one FROM "cmor_galleries_picture_galleries" WHERE "cmor_galleries_picture_galleries"."name" IS NULL LIMIT ? [["LIMIT", 1]]
24
+  (0.1ms) rollback transaction
25
+  (0.1ms) begin transaction
26
+  (0.1ms) SAVEPOINT active_record_1
27
+ Cmor::Galleries::PictureGallery Exists (0.8ms) SELECT 1 AS one FROM "cmor_galleries_picture_galleries" WHERE "cmor_galleries_picture_galleries"."name" = ? LIMIT ? [["name", "Picture Gallery #2"], ["LIMIT", 1]]
28
+ Cmor::Galleries::PictureGallery Create (0.2ms) INSERT INTO "cmor_galleries_picture_galleries" ("name", "created_at", "updated_at") VALUES (?, ?, ?) [["name", "Picture Gallery #2"], ["created_at", "2019-03-25 17:49:04.685635"], ["updated_at", "2019-03-25 17:49:04.685635"]]
29
+  (0.1ms) RELEASE SAVEPOINT active_record_1
30
+  (0.2ms) rollback transaction
31
+  (0.1ms) begin transaction
32
+  (0.1ms) rollback transaction
33
+  (0.1ms) begin transaction
34
+  (0.3ms) rollback transaction
35
+  (0.2ms) begin transaction
36
+  Disk Storage (1.6ms) Uploaded file to key: HpaXaXSTTBQhyk9pwjiXNpvs (checksum: PQckBuk+cVT3lBy73cnuAQ==)
37
+  (0.4ms) SAVEPOINT active_record_1
38
+ ActiveStorage::Blob Create (0.9ms) INSERT INTO "active_storage_blobs" ("key", "filename", "content_type", "metadata", "byte_size", "checksum", "created_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["key", "HpaXaXSTTBQhyk9pwjiXNpvs"], ["filename", "example.png"], ["content_type", "image/png"], ["metadata", "{\"identified\":true}"], ["byte_size", 9691], ["checksum", "PQckBuk+cVT3lBy73cnuAQ=="], ["created_at", "2019-03-25 17:49:04.887434"]]
39
+  (0.4ms) RELEASE SAVEPOINT active_record_1
40
+  (0.4ms) rollback transaction
41
+  (0.1ms) begin transaction
42
+  (0.2ms) rollback transaction
43
+  (0.2ms) begin transaction
44
+  Disk Storage (5.9ms) Uploaded file to key: B8o7CDJi1ubYmEcP3ZAGkEiM (checksum: PQckBuk+cVT3lBy73cnuAQ==)
45
+  (0.3ms) SAVEPOINT active_record_1
46
+ ActiveStorage::Blob Create (0.5ms) INSERT INTO "active_storage_blobs" ("key", "filename", "content_type", "metadata", "byte_size", "checksum", "created_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["key", "B8o7CDJi1ubYmEcP3ZAGkEiM"], ["filename", "example.png"], ["content_type", "image/png"], ["metadata", "{\"identified\":true}"], ["byte_size", 9691], ["checksum", "PQckBuk+cVT3lBy73cnuAQ=="], ["created_at", "2019-03-25 17:49:05.023546"]]
47
+  (0.2ms) RELEASE SAVEPOINT active_record_1
48
+  (0.3ms) SAVEPOINT active_record_1
49
+ Cmor::Galleries::PictureGallery Exists (0.4ms) SELECT 1 AS one FROM "cmor_galleries_picture_galleries" WHERE "cmor_galleries_picture_galleries"."name" = ? LIMIT ? [["name", "Picture Gallery #4"], ["LIMIT", 1]]
50
+ Cmor::Galleries::PictureGallery Create (0.4ms) INSERT INTO "cmor_galleries_picture_galleries" ("name", "created_at", "updated_at") VALUES (?, ?, ?) [["name", "Picture Gallery #4"], ["created_at", "2019-03-25 17:49:05.037260"], ["updated_at", "2019-03-25 17:49:05.037260"]]
51
+ ActiveStorage::Attachment Create (0.4ms) INSERT INTO "active_storage_attachments" ("name", "record_type", "record_id", "blob_id", "created_at") VALUES (?, ?, ?, ?, ?) [["name", "assets"], ["record_type", "Cmor::Galleries::PictureGallery"], ["record_id", 1], ["blob_id", 1], ["created_at", "2019-03-25 17:49:05.040357"]]
52
+ Cmor::Galleries::PictureDetail Load (0.4ms) SELECT "cmor_galleries_picture_details".* FROM "cmor_galleries_picture_details" WHERE "cmor_galleries_picture_details"."picture_gallery_id" = ? AND ("cmor_galleries_picture_details"."position" IS NOT NULL) ORDER BY "cmor_galleries_picture_details"."position" DESC LIMIT ? [["picture_gallery_id", 1], ["LIMIT", 1]]
53
+ Cmor::Galleries::PictureDetail Create (0.3ms) INSERT INTO "cmor_galleries_picture_details" ("picture_gallery_id", "asset_id", "position", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) [["picture_gallery_id", 1], ["asset_id", 1], ["position", 1], ["created_at", "2019-03-25 17:49:05.042893"], ["updated_at", "2019-03-25 17:49:05.042893"]]
54
+ Cmor::Galleries::PictureDetail Load (0.3ms) SELECT "cmor_galleries_picture_details".* FROM "cmor_galleries_picture_details" WHERE "cmor_galleries_picture_details"."picture_gallery_id" = ? AND ("cmor_galleries_picture_details"."position" IS NOT NULL) ORDER BY "cmor_galleries_picture_details"."position" DESC LIMIT ? [["picture_gallery_id", 1], ["LIMIT", 1]]
55
+ Cmor::Galleries::PictureDetail Create (0.2ms) INSERT INTO "cmor_galleries_picture_details" ("picture_gallery_id", "asset_id", "position", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) [["picture_gallery_id", 1], ["asset_id", 1], ["position", 2], ["created_at", "2019-03-25 17:49:05.047593"], ["updated_at", "2019-03-25 17:49:05.047593"]]
56
+ Cmor::Galleries::PictureGallery Update (0.5ms) UPDATE "cmor_galleries_picture_galleries" SET "updated_at" = ? WHERE "cmor_galleries_picture_galleries"."id" = ? [["updated_at", "2019-03-25 17:49:05.042145"], ["id", 1]]
57
+  (0.1ms) RELEASE SAVEPOINT active_record_1
58
+ [ActiveJob] Enqueued ActiveStorage::AnalyzeJob (Job ID: b25c28ce-e846-4096-a69f-b5cf4645b758) to Async(default) with arguments: #<GlobalID:0x0000000007a31d10 @uri=#<URI::GID gid://dummy/ActiveStorage::Blob/1>>
59
+ ActiveStorage::Blob Load (1.5ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
60
+  (0.5ms) rollback transaction
61
+ [ActiveJob] [ActiveStorage::AnalyzeJob] [b25c28ce-e846-4096-a69f-b5cf4645b758] Performing ActiveStorage::AnalyzeJob (Job ID: b25c28ce-e846-4096-a69f-b5cf4645b758) from Async(default) with arguments: #<GlobalID:0x0000000007974800 @uri=#<URI::GID gid://dummy/ActiveStorage::Blob/1>>
62
+ [ActiveJob] [ActiveStorage::AnalyzeJob] [b25c28ce-e846-4096-a69f-b5cf4645b758]  Disk Storage (1.8ms) Downloaded file from key: B8o7CDJi1ubYmEcP3ZAGkEiM
63
+ [ActiveJob] [ActiveStorage::AnalyzeJob] [b25c28ce-e846-4096-a69f-b5cf4645b758] Skipping image analysis because the mini_magick gem isn't installed
64
+ [ActiveJob] [ActiveStorage::AnalyzeJob] [b25c28ce-e846-4096-a69f-b5cf4645b758]  (0.1ms) begin transaction
65
+ [ActiveJob] [ActiveStorage::AnalyzeJob] [b25c28ce-e846-4096-a69f-b5cf4645b758] ActiveStorage::Blob Update (0.3ms) UPDATE "active_storage_blobs" SET "metadata" = ? WHERE "active_storage_blobs"."id" = ? [["metadata", "{\"identified\":true,\"analyzed\":true}"], ["id", 1]]
66
+ [ActiveJob] [ActiveStorage::AnalyzeJob] [b25c28ce-e846-4096-a69f-b5cf4645b758]  (0.2ms) commit transaction
67
+  (0.1ms) begin transaction
68
+ [ActiveJob] [ActiveStorage::AnalyzeJob] [b25c28ce-e846-4096-a69f-b5cf4645b758] Performed ActiveStorage::AnalyzeJob (Job ID: b25c28ce-e846-4096-a69f-b5cf4645b758) from Async(default) in 21.62ms
69
+  (0.1ms) rollback transaction
70
+  (0.2ms) begin transaction
71
+  (0.1ms) rollback transaction
72
+  (0.1ms) begin transaction
73
+  (0.2ms) rollback transaction
74
+  (0.1ms) begin transaction
75
+  (0.3ms) rollback transaction
76
+  (0.2ms) begin transaction
77
+  (0.3ms) rollback transaction
78
+  (0.2ms) begin transaction
79
+  (0.1ms) rollback transaction
80
+  (0.2ms) begin transaction
81
+  (0.2ms) rollback transaction
82
+  (0.1ms) begin transaction
83
+  (0.3ms) rollback transaction
84
+  (0.1ms) begin transaction
85
+  (0.1ms) rollback transaction
86
+  (0.2ms) begin transaction
87
+  (0.1ms) rollback transaction
88
+  (0.1ms) begin transaction
89
+  (0.2ms) rollback transaction
90
+  (0.1ms) begin transaction
91
+  (0.1ms) rollback transaction
92
+  (0.2ms) begin transaction
93
+  (0.1ms) rollback transaction
94
+  (0.1ms) begin transaction
95
+  (0.1ms) rollback transaction
96
+  (0.2ms) begin transaction
97
+  (0.1ms) rollback transaction
98
+  (0.3ms) begin transaction
99
+  (0.3ms) rollback transaction
100
+  (0.2ms) begin transaction
101
+  (0.1ms) rollback transaction
102
+  (0.1ms) begin transaction
103
+  (0.1ms) rollback transaction
104
+  (0.2ms) begin transaction
105
+  (0.2ms) rollback transaction
106
+  (0.1ms) begin transaction
107
+  (0.1ms) rollback transaction
108
+  (0.1ms) begin transaction
109
+  (0.1ms) rollback transaction
110
+  (0.1ms) begin transaction
111
+  (0.1ms) rollback transaction
112
+  (0.1ms) begin transaction
113
+  (0.2ms) rollback transaction
114
+  (0.2ms) begin transaction
115
+  (0.1ms) rollback transaction
116
+  (0.2ms) begin transaction
117
+  (0.1ms) rollback transaction
118
+  (0.1ms) begin transaction
119
+  (0.1ms) rollback transaction
120
+  (0.2ms) begin transaction
121
+  (0.1ms) rollback transaction
122
+  (0.2ms) begin transaction
123
+  (0.1ms) rollback transaction
124
+  (0.3ms) begin transaction
125
+  (0.1ms) rollback transaction
126
+  (0.3ms) begin transaction
127
+  (0.2ms) rollback transaction
128
+  (0.3ms) begin transaction
129
+  (0.2ms) rollback transaction
130
+  (1.0ms) begin transaction
131
+  (0.1ms) rollback transaction
132
+  (0.1ms) begin transaction
133
+  (0.1ms) rollback transaction
134
+  (0.1ms) begin transaction
135
+  (0.1ms) rollback transaction
136
+  (0.2ms) begin transaction
137
+  (0.4ms) rollback transaction
138
+  (0.3ms) begin transaction
139
+  (0.3ms) rollback transaction
140
+  (0.1ms) begin transaction
141
+  (0.1ms) rollback transaction
142
+  (0.2ms) begin transaction
143
+  (0.1ms) rollback transaction
@@ -0,0 +1 @@
1
+ 9d095a3642a6de2d80c204a909a899b8f3565e2c5b8b9789382e7b52e111c0e87fd813722a9b6d6fa0a2f7039ddc6d899236548a213c86e8653f11d1a1ba6c67
@@ -0,0 +1,17 @@
1
+ FactoryBot.define do
2
+ factory :cmor_galleries_picture_detail, class: 'Cmor::Galleries::PictureDetail' do
3
+ association :picture_gallery, factory: :cmor_galleries_picture_gallery
4
+ after(:build) { |resource|
5
+ assets = resource.picture_gallery.assets.attach(
6
+ io: File.open(File.join(Cmor::Galleries::Engine.root.join(*%w( spec files cmor galleries picture_details example.png)))),
7
+ filename: 'example.png',
8
+ content_type: 'image/png'
9
+ )
10
+ if Rails.version < "6.0.0"
11
+ resource.asset = assets.first
12
+ else
13
+ resource.asset = resource.picture_gallery.assets.first
14
+ end
15
+ }
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ FactoryBot.define do
2
+ factory :cmor_galleries_picture_gallery, class: 'Cmor::Galleries::PictureGallery' do
3
+ sequence(:name) { |i| "Picture Gallery ##{i}" }
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require 'rails_helper'
2
+
3
+ module Cmor::Galleries
4
+ RSpec.describe PictureDetail, type: :model do
5
+ pending "add some examples to (or delete) #{__FILE__}"
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ require 'rails_helper'
2
+
3
+ module Cmor::Galleries
4
+ RSpec.describe PictureGallery, type: :model do
5
+ it { expect(subject).to validate_presence_of(:name) }
6
+ it { expect(subject).to validate_uniqueness_of(:name) }
7
+ end
8
+ end
@@ -0,0 +1,50 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe 'ActiveRecord::Base models', type: :model do
4
+ DEFAULT_SPECS_TO_RUN = [
5
+ :is_an_active_record,
6
+ :is_instanciable,
7
+ :valid_with_correct_attributes,
8
+ :not_valid_with_empty_attributes,
9
+ :saves_with_valid_attributes
10
+ ]
11
+
12
+ {
13
+ Cmor::Galleries::PictureGallery => {},
14
+ Cmor::Galleries::PictureDetail => {},
15
+ }.each do |model, options|
16
+ options.reverse_merge!(specs_to_run: DEFAULT_SPECS_TO_RUN, specs_to_skip: [])
17
+ specs_to_run = options.delete(:specs_to_run)
18
+ specs_to_skip = options.delete(:specs_to_skip)
19
+ specs = specs_to_run - specs_to_skip
20
+
21
+ describe model do
22
+ it 'is an ActiveRecord::Base' do
23
+ expect(ActiveRecord::Base.descendants).to include(model)
24
+ end if specs.include?(:is_an_active_record)
25
+
26
+ it 'is instanciable' do
27
+ instance = model.new
28
+ expect(instance).to be_a(model)
29
+ end if specs.include?(:is_instanciable)
30
+
31
+ it 'is valid with correct attribute values' do
32
+ instance = build(model.to_s.tableize.singularize.underscore.tr('/', '_'))
33
+
34
+ instance.valid?
35
+ expect(instance.errors.full_messages).to eq([])
36
+ end if specs.include?(:valid_with_correct_attributes)
37
+
38
+ it 'is not valid with empty attributes' do
39
+ instance = model.new
40
+ expect(instance).not_to be_valid
41
+ end if specs.include?(:not_valid_with_empty_attributes)
42
+
43
+ it 'saves with valid attributes' do
44
+ instance = build(model.to_s.tableize.singularize.underscore.tr('/', '_'))
45
+ expect(instance.save).to be_truthy
46
+ expect(instance).to be_persisted
47
+ end if specs.include?(:saves_with_valid_attributes)
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,41 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe 'Translations', type: :model do
4
+ {
5
+ Cmor::Galleries::PictureGallery => {},
6
+ Cmor::Galleries::PictureDetail => {},
7
+ }.each do |model, options|
8
+ I18n.available_locales.each do |locale|
9
+ I18n.locale = locale
10
+
11
+ describe "for locale #{locale}:" do
12
+ describe "#{model} translations" do
13
+ it 'include one' do
14
+ I18n.locale = locale
15
+ i18n_key = ['activerecord', 'models', model.name.underscore].join('.')
16
+ i18n_options = {}
17
+ expect(I18n.translate!(i18n_key, options)[:one]).to be_a(String)
18
+ end
19
+
20
+ it 'include other' do
21
+ I18n.locale = locale
22
+ i18n_key = ['activerecord', 'models', model.name.underscore].join('.')
23
+ i18n_options = {}
24
+ expect(I18n.translate!(i18n_key, options)[:other]).to be_a(String)
25
+ end
26
+
27
+ describe 'for attributes' do
28
+
29
+ model.column_names.each do |column_name|
30
+ it "include #{column_name}" do
31
+ I18n.locale = locale
32
+ i18n_key = ['activerecord', 'attributes', model.name.underscore, column_name].join('.')
33
+ expect(I18n.translate!(i18n_key)).to be_a(String)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end