enju_seed 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +28 -0
  3. data/app/controllers/profiles_controller.rb +1 -1
  4. data/app/controllers/roles_controller.rb +1 -1
  5. data/app/models/identity.rb +1 -1
  6. data/app/models/profile.rb +1 -1
  7. data/app/models/role.rb +1 -1
  8. data/app/models/user_has_role.rb +1 -4
  9. data/app/views/roles/show.html.erb +0 -5
  10. data/lib/enju_seed/version.rb +1 -1
  11. data/lib/generators/enju_seed/setup/setup_generator.rb +9 -0
  12. data/lib/generators/enju_seed/setup/templates/db/fixtures/roles.yml +38 -0
  13. data/lib/tasks/enju_seed_tasks.rake +8 -4
  14. data/spec/dummy/app/models/application_record.rb +3 -0
  15. data/spec/dummy/app/models/user.rb +1 -1
  16. data/spec/dummy/config/application.rb +1 -1
  17. data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +0 -8
  18. data/spec/dummy/db/migrate/20160319144230_create_issn_records.rb +11 -0
  19. data/spec/dummy/db/migrate/20160506144040_create_isbn_records.rb +11 -0
  20. data/spec/dummy/db/migrate/20160801080612_add_most_recent_to_import_request_transitions.rb +9 -0
  21. data/spec/dummy/db/migrate/20160801080619_add_most_recent_to_resource_import_file_transitions.rb +9 -0
  22. data/spec/dummy/db/migrate/20160801080637_add_most_recent_to_resource_export_file_transitions.rb +9 -0
  23. data/spec/dummy/db/migrate/20160801080643_add_most_recent_to_agent_import_file_transitions.rb +9 -0
  24. data/spec/dummy/db/migrate/20160811102604_add_picture_width_to_picture_file.rb +6 -0
  25. data/spec/dummy/db/migrate/20160814165332_add_most_recent_to_message_request_transitions.rb +9 -0
  26. data/spec/dummy/db/migrate/20160820004638_add_attachment_attachment_to_carrier_types.rb +11 -0
  27. data/spec/dummy/db/migrate/20170116134107_create_issn_record_and_manifestations.rb +11 -0
  28. data/spec/dummy/db/migrate/20170116134120_create_isbn_record_and_manifestations.rb +11 -0
  29. data/spec/dummy/db/migrate/20171119051258_set_not_null_to_manifestation_id_on_items.rb +5 -0
  30. data/spec/dummy/db/migrate/20180107160726_add_constraints_to_most_recent_for_user_import_file_transitions.rb +13 -0
  31. data/spec/dummy/db/migrate/20180107160740_add_constraints_to_most_recent_for_user_export_file_transitions.rb +13 -0
  32. data/spec/dummy/db/migrate/20180107161311_add_constraints_to_most_recent_for_agent_import_file_transitions.rb +13 -0
  33. data/spec/dummy/db/migrate/20180107161331_add_constraints_to_most_recent_for_resource_import_file_transitions.rb +13 -0
  34. data/spec/dummy/db/migrate/20180107161347_add_constraints_to_most_recent_for_resource_export_file_transitions.rb +13 -0
  35. data/spec/dummy/db/migrate/20180107161410_add_constraints_to_most_recent_for_import_request_transitions.rb +13 -0
  36. data/spec/dummy/db/migrate/20180107162659_add_constraints_to_most_recent_for_message_transitions.rb +13 -0
  37. data/spec/dummy/db/migrate/20180107162711_add_constraints_to_most_recent_for_message_request_transitions.rb +13 -0
  38. data/spec/dummy/db/migrate/20181026064038_add_login_banner_to_library_group.rb +6 -0
  39. data/spec/dummy/db/migrate/20181030072731_add_not_null_to_position_on_carrier_type.rb +14 -0
  40. data/spec/dummy/db/migrate/20181030074920_add_not_null_to_position_on_library.rb +14 -0
  41. data/spec/dummy/db/migrate/20190208135957_create_active_storage_tables.active_storage.rb +27 -0
  42. data/spec/dummy/db/migrate/20190311154610_create_periodicals.rb +10 -0
  43. data/spec/dummy/db/migrate/20190314151124_add_full_name_translations_to_create.rb +7 -0
  44. data/spec/dummy/db/schema.rb +116 -25
  45. data/spec/models/user_has_role_spec.rb +0 -1
  46. data/spec/views/profiles/show.html.erb_spec.rb +1 -1
  47. data/spec/views/roles/edit.html.erb_spec.rb +18 -0
  48. data/spec/views/roles/index.html.erb_spec.rb +14 -0
  49. data/spec/views/roles/new.html.erb_spec.rb +18 -0
  50. data/spec/views/roles/show.html.erb_spec.rb +14 -0
  51. metadata +321 -243
  52. data/README.rdoc +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b9840693279f858c771db87616a36faac54f576468c54fbe7f90ee3353b323d
4
- data.tar.gz: 3bfbfdbaf6b9f76e53692c8e4bdf297d6a7926bfcf61efc6a0b980b062ccf69f
3
+ metadata.gz: 0b5d4b5e670279c1d6e48e488585f167928ea1ae564a63bd40d873b4c00d6c83
4
+ data.tar.gz: 57b3afe3052d84eeca383536c8cfd7099e7d44262328791448d10032e599de3c
5
5
  SHA512:
6
- metadata.gz: b83d9d6441b55998b8553c6fa56c3433f657c5105cb82ed3cfbae77abc8a83f61c2057b6df71b56e50501cd4ba520579c911dd3a7e039e0af6fadd1b85aed03b
7
- data.tar.gz: e3c548f4bc03ba8ec07507be460c1d97c60f1c4c537e71f62b538ead89f3ffbf92e2403a58b3a46807c7c42eec978e76cc7b8be429e82b11267dfde55bb62346
6
+ metadata.gz: 80d86dd10500be037306e39a879547fe4d04b38053aa0c0516bf5669b3d069e2f57003663d2ab048f4f16e0d087080fa00d656d42d684fa8eb5ede830873aef0
7
+ data.tar.gz: 9dc73692ebcae34d1b8060acf9ca8cb3e4baa7f781cd9e0c3f8465e54781e61f6737892b2b387f9eaabeb2dbc5f6464f1b139f4c7f434296efeb84dc77f620d4
@@ -0,0 +1,28 @@
1
+ # EnjuSeed
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'enju_seed'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install enju_seed
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -132,7 +132,7 @@ class ProfilesController < ApplicationController
132
132
  # PUT /profiles/1
133
133
  # PUT /profiles/1.json
134
134
  def update
135
- @profile.update_attributes(profile_update_params)
135
+ @profile.update(profile_update_params)
136
136
  if @profile.user
137
137
  if @profile.user.auto_generated_password == "1"
138
138
  password = @profile.user.set_auto_generated_password
@@ -35,7 +35,7 @@ class RolesController < ApplicationController
35
35
  end
36
36
 
37
37
  respond_to do |format|
38
- if @role.update_attributes(role_params)
38
+ if @role.update(role_params)
39
39
  format.html { redirect_to @role, notice: t('controller.successfully_updated', model: t('activerecord.models.role')) }
40
40
  format.json { head :no_content }
41
41
  else
@@ -1,4 +1,4 @@
1
- class Identity < ActiveRecord::Base
1
+ class Identity < ApplicationRecord
2
2
  belongs_to :profile
3
3
  validates :name, presence: true, uniqueness: {scope: :provider}
4
4
  validates :provider, presence: true
@@ -1,4 +1,4 @@
1
- class Profile < ActiveRecord::Base
1
+ class Profile < ApplicationRecord
2
2
  scope :administrators, -> { joins(user: :role).where('roles.name = ?', 'Administrator') }
3
3
  scope :librarians, -> { joins(user: :role).where('roles.name = ? OR roles.name = ?', 'Administrator', 'Librarian') }
4
4
  belongs_to :user, dependent: :destroy, optional: true
@@ -1,4 +1,4 @@
1
- class Role < ActiveRecord::Base
1
+ class Role < ApplicationRecord
2
2
  include MasterModel
3
3
  validates :name, presence: true, format: { with: /\A[A-Za-z][a-z_,]*[a-z]\z/ }
4
4
  has_many :user_has_roles
@@ -1,10 +1,7 @@
1
- class UserHasRole < ActiveRecord::Base
1
+ class UserHasRole < ApplicationRecord
2
2
  belongs_to :user
3
3
  belongs_to :role
4
4
  accepts_nested_attributes_for :role
5
-
6
- # validates_uniqueness_of :role_id, scope: :user_id
7
- # validates_presence_of :role_id, :user_id
8
5
  end
9
6
 
10
7
  # == Schema Information
@@ -13,11 +13,6 @@
13
13
  <%= @role.display_name.localize -%>
14
14
  </p>
15
15
 
16
- <p>
17
- <strong><%= t('activerecord.attributes.role.score') -%>:</strong>
18
- <%= @role.score -%>
19
- </p>
20
-
21
16
  <p>
22
17
  <strong><%= t('activerecord.attributes.role.note') -%>:</strong>
23
18
  <%= @role.note -%>
@@ -1,3 +1,3 @@
1
1
  module EnjuSeed
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
@@ -0,0 +1,9 @@
1
+ class EnjuSeed::SetupGenerator < Rails::Generators::Base
2
+ source_root File.expand_path('../templates', __FILE__)
3
+ desc "Create a setup file for Next-L Enju"
4
+
5
+ def copy_setup_files
6
+ directory("db/fixtures", "db/fixtures/enju_seed")
7
+ rake("enju_seed_engine:install:migrations")
8
+ end
9
+ end
@@ -0,0 +1,38 @@
1
+ ---
2
+ role_00001:
3
+ name: Guest
4
+ display_name: Guest
5
+ id: 1
6
+ note:
7
+ position: 1
8
+ role_00002:
9
+ name: User
10
+ display_name: User
11
+ id: 2
12
+ note:
13
+ position: 2
14
+ role_00003:
15
+ name: Librarian
16
+ display_name: Librarian
17
+ id: 3
18
+ note:
19
+ position: 3
20
+ role_00004:
21
+ name: Administrator
22
+ display_name: Administrator
23
+ id: 4
24
+ note:
25
+ position: 4
26
+
27
+ # == Schema Information
28
+ #
29
+ # Table name: roles
30
+ #
31
+ # id :bigint(8) not null, primary key
32
+ # name :string not null
33
+ # display_name_translations :jsonb not null
34
+ # note :text
35
+ # position :integer
36
+ # created_at :datetime not null
37
+ # updated_at :datetime not null
38
+ #
@@ -1,4 +1,8 @@
1
- # desc "Explaining what the task does"
2
- # task :enju_seed do
3
- # # Task goes here
4
- # end
1
+ namespace :enju_seed do
2
+ desc "create initial records for enju_seed"
3
+ task setup: :environment do
4
+ Dir.glob(Rails.root.to_s + '/db/fixtures/enju_seed/*.yml').each do |file|
5
+ ActiveRecord::FixtureSet.create_fixtures('db/fixtures/enju_seed', File.basename(file, '.*'))
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -1,4 +1,4 @@
1
- class User < ActiveRecord::Base
1
+ class User < ApplicationRecord
2
2
  devise :database_authenticatable, #:registerable,
3
3
  :recoverable, :rememberable, :trackable, #, :validatable
4
4
  :lockable, lock_strategy: :none, unlock_strategy: :none
@@ -9,7 +9,7 @@ require "enju_leaf"
9
9
  module Dummy
10
10
  class Application < Rails::Application
11
11
  # Initialize configuration defaults for originally generated Rails version.
12
- config.load_defaults 5.1
12
+ config.load_defaults 5.2
13
13
 
14
14
  # Settings in config/environments/* take precedence over those specified here.
15
15
  # Application configuration should go into files in config/initializers
@@ -8,19 +8,11 @@ class AddTranslationTableToLibraryGroup < ActiveRecord::Migration[4.2]
8
8
  migrate_data: true
9
9
  })
10
10
  end
11
-
12
- if defined?(AwesomeHstoreTranslate)
13
- add_column :library_groups, :login_banner, :hstore
14
- end
15
11
  end
16
12
 
17
13
  def down
18
14
  if defined?(Globalize)
19
15
  LibraryGroup.drop_translation_table! migrate_data: true
20
16
  end
21
-
22
- if defined?(AwesomeHstoreTranslate)
23
- remove_column :library_groups, :login_banner
24
- end
25
17
  end
26
18
  end
@@ -0,0 +1,11 @@
1
+ class CreateIssnRecords < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :issn_records do |t|
4
+ t.string :body, index: {unique: true}, null: false
5
+ t.string :issn_type
6
+ t.string :source
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateIsbnRecords < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :isbn_records do |t|
4
+ t.string :body, index: {unique: true}, null: false
5
+ t.string :isbn_type
6
+ t.string :source
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ class AddMostRecentToImportRequestTransitions < ActiveRecord::Migration[4.2]
2
+ def up
3
+ add_column :import_request_transitions, :most_recent, :boolean, null: true
4
+ end
5
+
6
+ def down
7
+ remove_column :import_request_transitions, :most_recent
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddMostRecentToResourceImportFileTransitions < ActiveRecord::Migration[4.2]
2
+ def up
3
+ add_column :resource_import_file_transitions, :most_recent, :boolean, null: true
4
+ end
5
+
6
+ def down
7
+ remove_column :resource_import_file_transitions, :most_recent
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddMostRecentToResourceExportFileTransitions < ActiveRecord::Migration[4.2]
2
+ def up
3
+ add_column :resource_export_file_transitions, :most_recent, :boolean, null: true
4
+ end
5
+
6
+ def down
7
+ remove_column :resource_export_file_transitions, :most_recent
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddMostRecentToAgentImportFileTransitions < ActiveRecord::Migration[4.2]
2
+ def up
3
+ add_column :agent_import_file_transitions, :most_recent, :boolean, null: true
4
+ end
5
+
6
+ def down
7
+ remove_column :agent_import_file_transitions, :most_recent
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ class AddPictureWidthToPictureFile < ActiveRecord::Migration[4.2]
2
+ def change
3
+ add_column :picture_files, :picture_width, :integer
4
+ add_column :picture_files, :picture_height, :integer
5
+ end
6
+ end
@@ -0,0 +1,9 @@
1
+ class AddMostRecentToMessageRequestTransitions < ActiveRecord::Migration[5.2]
2
+ def up
3
+ add_column :message_request_transitions, :most_recent, :boolean, null: true
4
+ end
5
+
6
+ def down
7
+ remove_column :message_request_transitions, :most_recent
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ class AddAttachmentAttachmentToCarrierTypes < ActiveRecord::Migration[4.2]
2
+ def self.up
3
+ change_table :carrier_types do |t|
4
+ t.attachment :attachment
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ remove_attachment :carrier_types, :attachment
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateIssnRecordAndManifestations < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :issn_record_and_manifestations do |t|
4
+ t.references :issn_record, foreign_key: true, on_delete: :cascade, null: false
5
+ t.references :manifestation, foreign_key: true, on_delete: :cascade, null: false
6
+ t.integer :position
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateIsbnRecordAndManifestations < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :isbn_record_and_manifestations do |t|
4
+ t.references :isbn_record, foreign_key: true, on_delete: :cascade, null: false
5
+ t.references :manifestation, foreign_key: true, null: false, on_delete: :cascade
6
+ t.integer :position
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ class SetNotNullToManifestationIdOnItems < ActiveRecord::Migration[4.2]
2
+ def change
3
+ change_column_null :items, :manifestation_id, false
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ class AddConstraintsToMostRecentForUserImportFileTransitions < ActiveRecord::Migration[4.2]
2
+ disable_ddl_transaction!
3
+
4
+ def up
5
+ add_index :user_import_file_transitions, [:user_import_file_id, :most_recent], unique: true, where: "most_recent", name: "index_user_import_file_transitions_parent_most_recent" #, algorithm: :concurrently
6
+ change_column_null :user_import_file_transitions, :most_recent, false
7
+ end
8
+
9
+ def down
10
+ remove_index :user_import_file_transitions, name: "index_user_import_file_transitions_parent_most_recent"
11
+ change_column_null :user_import_file_transitions, :most_recent, true
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class AddConstraintsToMostRecentForUserExportFileTransitions < ActiveRecord::Migration[4.2]
2
+ disable_ddl_transaction!
3
+
4
+ def up
5
+ add_index :user_export_file_transitions, [:user_export_file_id, :most_recent], unique: true, where: "most_recent", name: "index_user_export_file_transitions_parent_most_recent" #, algorithm: :concurrently
6
+ change_column_null :user_export_file_transitions, :most_recent, false
7
+ end
8
+
9
+ def down
10
+ remove_index :user_export_file_transitions, name: "index_user_export_file_transitions_parent_most_recent"
11
+ change_column_null :user_export_file_transitions, :most_recent, true
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class AddConstraintsToMostRecentForAgentImportFileTransitions < ActiveRecord::Migration[4.2]
2
+ disable_ddl_transaction!
3
+
4
+ def up
5
+ add_index :agent_import_file_transitions, [:agent_import_file_id, :most_recent], unique: true, where: "most_recent", name: "index_agent_import_file_transitions_parent_most_recent" #, algorithm: :concurrently
6
+ change_column_null :agent_import_file_transitions, :most_recent, false
7
+ end
8
+
9
+ def down
10
+ remove_index :agent_import_file_transitions, name: "index_agent_import_file_transitions_parent_most_recent"
11
+ change_column_null :agent_import_file_transitions, :most_recent, true
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class AddConstraintsToMostRecentForResourceImportFileTransitions < ActiveRecord::Migration[4.2]
2
+ disable_ddl_transaction!
3
+
4
+ def up
5
+ add_index :resource_import_file_transitions, [:resource_import_file_id, :most_recent], unique: true, where: "most_recent", name: "index_resource_import_file_transitions_parent_most_recent" #, algorithm: :concurrently
6
+ change_column_null :resource_import_file_transitions, :most_recent, false
7
+ end
8
+
9
+ def down
10
+ remove_index :resource_import_file_transitions, name: "index_resource_import_file_transitions_parent_most_recent"
11
+ change_column_null :resource_import_file_transitions, :most_recent, true
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class AddConstraintsToMostRecentForResourceExportFileTransitions < ActiveRecord::Migration[4.2]
2
+ disable_ddl_transaction!
3
+
4
+ def up
5
+ add_index :resource_export_file_transitions, [:resource_export_file_id, :most_recent], unique: true, where: "most_recent", name: "index_resource_export_file_transitions_parent_most_recent" #, algorithm: :concurrently
6
+ change_column_null :resource_export_file_transitions, :most_recent, false
7
+ end
8
+
9
+ def down
10
+ remove_index :resource_export_file_transitions, name: "index_resource_export_file_transitions_parent_most_recent"
11
+ change_column_null :resource_export_file_transitions, :most_recent, true
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class AddConstraintsToMostRecentForImportRequestTransitions < ActiveRecord::Migration[4.2]
2
+ disable_ddl_transaction!
3
+
4
+ def up
5
+ add_index :import_request_transitions, [:import_request_id, :most_recent], unique: true, where: "most_recent", name: "index_import_request_transitions_parent_most_recent" #, algorithm: :concurrently
6
+ change_column_null :import_request_transitions, :most_recent, false
7
+ end
8
+
9
+ def down
10
+ remove_index :import_request_transitions, name: "index_import_request_transitions_parent_most_recent"
11
+ change_column_null :import_request_transitions, :most_recent, true
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class AddConstraintsToMostRecentForMessageTransitions < ActiveRecord::Migration[5.2]
2
+ disable_ddl_transaction!
3
+
4
+ def up
5
+ add_index :message_transitions, [:message_id, :most_recent], unique: true, where: "most_recent", name: "index_message_transitions_parent_most_recent" # , algorithm: :concurrently
6
+ change_column_null :message_transitions, :most_recent, false
7
+ end
8
+
9
+ def down
10
+ remove_index :message_transitions, name: "index_message_transitions_parent_most_recent"
11
+ change_column_null :message_transitions, :most_recent, true
12
+ end
13
+ end