solidus_user_roles 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +73 -0
  3. data/.gem_release.yml +5 -0
  4. data/.github/stale.yml +1 -0
  5. data/.github_changelog_generator +2 -0
  6. data/.gitignore +21 -0
  7. data/.rspec +2 -0
  8. data/.rubocop.yml +5 -0
  9. data/CHANGELOG.md +1 -0
  10. data/Gemfile +39 -0
  11. data/LICENSE +26 -0
  12. data/README.md +83 -0
  13. data/Rakefile +6 -0
  14. data/app/controllers/spree/admin/roles_controller.rb +8 -0
  15. data/app/decorators/models/solidus_user_roles/spree/role_decorator.rb +26 -0
  16. data/app/models/spree/permission_set.rb +11 -0
  17. data/app/models/spree/permission_sets/role_management.rb +35 -0
  18. data/app/models/spree/role_permission.rb +8 -0
  19. data/app/overrides/user_sub_menu.rb +13 -0
  20. data/app/views/spree/admin/roles/_form.html.erb +38 -0
  21. data/app/views/spree/admin/roles/edit.html.erb +19 -0
  22. data/app/views/spree/admin/roles/index.html.erb +54 -0
  23. data/app/views/spree/admin/roles/new.html.erb +23 -0
  24. data/bin/console +17 -0
  25. data/bin/rails +7 -0
  26. data/bin/rails-engine +13 -0
  27. data/bin/rails-sandbox +16 -0
  28. data/bin/rake +7 -0
  29. data/bin/sandbox +78 -0
  30. data/bin/setup +8 -0
  31. data/config/locales/en.yml +16 -0
  32. data/config/routes.rb +7 -0
  33. data/db/migrate/20160406142441_create_spree_permission_sets.rb +9 -0
  34. data/db/migrate/20160406142933_create_spree_roles_permissions.rb +9 -0
  35. data/db/seeds.rb +5 -0
  36. data/lib/generators/solidus_user_roles/install/install_generator.rb +31 -0
  37. data/lib/generators/solidus_user_roles/install/templates/initializer.rb +6 -0
  38. data/lib/solidus_user_roles/configuration.rb +21 -0
  39. data/lib/solidus_user_roles/engine.rb +44 -0
  40. data/lib/solidus_user_roles/testing_support/factories.rb +8 -0
  41. data/lib/solidus_user_roles/version.rb +5 -0
  42. data/lib/solidus_user_roles.rb +5 -0
  43. data/lib/tasks/load_seeds.rake +10 -0
  44. data/solidus_user_roles.gemspec +37 -0
  45. data/spec/controllers/spree/admin/roles_controller_spec.rb +82 -0
  46. data/spec/models/spree/permission_set_spec.rb +7 -0
  47. data/spec/models/spree/role_permission_spec.rb +6 -0
  48. data/spec/models/spree/role_spec.rb +45 -0
  49. data/spec/spec_helper.rb +28 -0
  50. data/spec/support/shoulda.rb +8 -0
  51. metadata +165 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0fd3c45b5071e9d4865c51b4ef3696b674b75f95e837754361f563f4c571a90f
4
+ data.tar.gz: a8cfbdb44bb6491547f58b6e5fc13cae4ff210236ffc4b744a26a7e6cc77304c
5
+ SHA512:
6
+ metadata.gz: 998aa0a09c26b99619c4cf5a25fab0dcce2028bc0059491ab9032ad70c8847fc774edfc60521de3ef6894ef147e89c3a8325ff2853797ffa99c13604e2552f6d
7
+ data.tar.gz: aa1a0db693a3617eebfad61c99f0215a55662f119beb75e1fcdc0f90b82aa0017fbbdd2b6ef45362fa6c94ab0f590eedd0fe61493a405e6caff5ed3a461c52ad
@@ -0,0 +1,73 @@
1
+ version: 2.1
2
+
3
+ orbs:
4
+ # Required for feature specs.
5
+ browser-tools: circleci/browser-tools@1.1
6
+
7
+ # Always take the latest version of the orb, this allows us to
8
+ # run specs against Solidus supported versions only without the need
9
+ # to change this configuration every time a Solidus version is released
10
+ # or goes EOL.
11
+ solidusio_extensions: solidusio/extensions@volatile
12
+
13
+ jobs:
14
+ run-specs:
15
+ parameters:
16
+ solidus:
17
+ type: string
18
+ default: main
19
+ db:
20
+ type: string
21
+ default: "postgres"
22
+ ruby:
23
+ type: string
24
+ default: "3.2"
25
+ executor:
26
+ name: solidusio_extensions/<< parameters.db >>
27
+ ruby_version: << parameters.ruby >>
28
+ steps:
29
+ - checkout
30
+ - browser-tools/install-chrome
31
+ - solidusio_extensions/run-tests-solidus-<< parameters.solidus >>
32
+
33
+ lint-code:
34
+ executor:
35
+ name: solidusio_extensions/sqlite
36
+ ruby_version: "3.0"
37
+ steps:
38
+ - solidusio_extensions/lint-code
39
+
40
+ workflows:
41
+ "Run specs on supported Solidus versions":
42
+ jobs:
43
+ - run-specs:
44
+ name: &name "run-specs-solidus-<< matrix.solidus >>-ruby-<< matrix.ruby >>-db-<< matrix.db >>"
45
+ matrix:
46
+ parameters: { solidus: ["main"], ruby: ["3.2"], db: ["postgres"] }
47
+ - run-specs:
48
+ name: *name
49
+ matrix:
50
+ parameters: { solidus: ["current"], ruby: ["3.1"], db: ["mysql"] }
51
+ - run-specs:
52
+ name: *name
53
+ matrix:
54
+ parameters: { solidus: ["older"], ruby: ["3.0"], db: ["sqlite"] }
55
+ - lint-code
56
+
57
+ "Weekly run specs against main":
58
+ triggers:
59
+ - schedule:
60
+ cron: "0 0 * * 4" # every Thursday
61
+ filters:
62
+ branches:
63
+ only:
64
+ - main
65
+ jobs:
66
+ - run-specs:
67
+ name: *name
68
+ matrix:
69
+ parameters: { solidus: ["main"], ruby: ["3.2"], db: ["postgres"] }
70
+ - run-specs:
71
+ name: *name
72
+ matrix:
73
+ parameters: { solidus: ["current"], ruby: ["3.1"], db: ["mysql"] }
data/.gem_release.yml ADDED
@@ -0,0 +1,5 @@
1
+ bump:
2
+ recurse: false
3
+ file: 'lib/solidus_user_roles/version.rb'
4
+ message: Bump SolidusUserRoles to %{version}
5
+ tag: true
data/.github/stale.yml ADDED
@@ -0,0 +1 @@
1
+ _extends: .github
@@ -0,0 +1,2 @@
1
+ issues=false
2
+ exclude-labels=infrastructure
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ \#*
3
+ *~
4
+ .#*
5
+ .DS_Store
6
+ .idea
7
+ .project
8
+ .sass-cache
9
+ coverage
10
+ Gemfile.lock
11
+ Gemfile-local
12
+ tmp
13
+ nbproject
14
+ pkg
15
+ *.swp
16
+ spec/dummy
17
+ spec/examples.txt
18
+ /sandbox
19
+ .rvmrc
20
+ .ruby-version
21
+ .ruby-gemset
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ require:
2
+ - solidus_dev_support/rubocop
3
+
4
+ AllCops:
5
+ NewCops: disable
data/CHANGELOG.md ADDED
@@ -0,0 +1 @@
1
+ # Changelog
data/Gemfile ADDED
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
+
6
+ branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
7
+ gem 'solidus', github: 'solidusio/solidus', branch: branch
8
+
9
+ # The solidus_frontend gem has been pulled out since v3.2
10
+ gem 'solidus_frontend', github: 'solidusio/solidus_frontend' if branch == 'master'
11
+ gem 'solidus_frontend' if branch >= 'v3.2' # rubocop:disable Bundler/DuplicatedGem
12
+
13
+ # Needed to help Bundler figure out how to resolve dependencies,
14
+ # otherwise it takes forever to resolve them.
15
+ # See https://github.com/bundler/bundler/issues/6677
16
+ gem 'rails', '>0.a'
17
+
18
+ # Provides basic authentication functionality for testing parts of your engine
19
+ gem 'solidus_auth_devise'
20
+
21
+ case ENV.fetch('DB', nil)
22
+ when 'mysql'
23
+ gem 'mysql2'
24
+ when 'postgresql'
25
+ gem 'pg'
26
+ else
27
+ gem 'sqlite3'
28
+ end
29
+
30
+ gem 'rails-controller-testing', group: :test
31
+
32
+ gemspec
33
+
34
+ # Use a local Gemfile to include development dependencies that might not be
35
+ # relevant for the project or for other contributors, e.g. pry-byebug.
36
+ #
37
+ # We use `send` instead of calling `eval_gemfile` to work around an issue with
38
+ # how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
39
+ send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2023 Allison Reilly
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Solidus nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # Solidus User Roles
2
+
3
+ [![CircleCI](https://circleci.com/gh/cpfergus1/solidus_user_roles.svg?style=shield)](https://circleci.com/gh/cpfergus1/solidus_user_roles)
4
+ [![codecov](https://codecov.io/gh/cpfergus1/solidus_user_roles/branch/master/graph/badge.svg)](https://codecov.io/gh/cpfergus1/solidus_user_roles)
5
+
6
+ <!-- Explain what your extension does. -->
7
+
8
+ ## Installation
9
+
10
+ Add solidus_user_roles to your Gemfile:
11
+
12
+ ```ruby
13
+ gem 'solidus_user_roles', github: 'solidusio-contrb/solidus_user_roles'
14
+ ```
15
+
16
+ Bundle your dependencies and run the installation generator:
17
+
18
+ ```shell
19
+ bundle
20
+ bundle exec rails g solidus_user_roles:install
21
+ ```
22
+
23
+ Remember to seed or run:
24
+ ```shell
25
+ rake solidus_user_roles:load_seeds
26
+ ```
27
+
28
+ Admin Panel
29
+ -----------
30
+ An admin is the only user who has the ability to add or remove roles from other users.
31
+ ![image](https://github.com/cpfergus1/solidus_user_roles/assets/68167430/8109fe7e-d098-42c8-a03a-ad1bec273b8c)
32
+ ![image](https://github.com/cpfergus1/solidus_user_roles/assets/68167430/311d8e38-e801-401d-9fe8-f232435001ad)
33
+ ![image](https://github.com/cpfergus1/solidus_user_roles/assets/68167430/6f248635-054c-4adc-9fdf-85108acd06c8)
34
+ ## Development
35
+
36
+ ### Testing the extension
37
+
38
+ First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
39
+ app if it does not exist, then it will run specs. The dummy app can be regenerated by using
40
+ `bin/rake extension:test_app`.
41
+
42
+ ```shell
43
+ bin/rake
44
+ ```
45
+
46
+ To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
47
+
48
+ ```shell
49
+ bundle exec rubocop
50
+ ```
51
+
52
+ When testing your application's integration with this extension you may use its factories.
53
+ You can load Solidus core factories along with this extension's factories using this statement:
54
+
55
+ ```ruby
56
+ SolidusDevSupport::TestingSupport::Factories.load_for(SolidusUserRoles::Engine)
57
+ ```
58
+
59
+ ### Running the sandbox
60
+
61
+ To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
62
+ the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
63
+ `sandbox/bin/rails`.
64
+
65
+ Here's an example:
66
+
67
+ ```
68
+ $ bin/rails server
69
+ => Booting Puma
70
+ => Rails 6.0.2.1 application starting in development
71
+ * Listening on tcp://127.0.0.1:3000
72
+ Use Ctrl-C to stop
73
+ ```
74
+
75
+ ### Releasing new versions
76
+
77
+ Please refer to the [dedicated page](https://github.com/solidusio/solidus/wiki/How-to-release-extensions) in the Solidus wiki.
78
+
79
+
80
+ ## License
81
+ Fork of https://github.com/boomerdigital/solidus_user_roles
82
+
83
+ Copyright (c) 2023 Allison Reilly, released under the New BSD License.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'solidus_dev_support/rake_tasks'
4
+ SolidusDevSupport::RakeTasks.install
5
+
6
+ task default: 'extension:specs'
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ module Admin
5
+ class RolesController < ResourceController
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusUserRoles
4
+ module Spree
5
+ module RoleDecorator
6
+ def self.prepended(base)
7
+ base.has_many :role_permissions, dependent: :destroy
8
+ base.has_many :permission_sets, through: :role_permissions
9
+
10
+ base.scope :non_base_roles, -> { where.not(name: ['admin', 'user']) }
11
+ base.validates_uniqueness_of :name, case_sensitive: false
12
+ base.after_save :assign_permissions
13
+ end
14
+
15
+ def permission_sets_constantized
16
+ permission_sets.map(&:set).map(&:constantize)
17
+ end
18
+
19
+ def assign_permissions
20
+ ::Spree::Config.roles.assign_permissions name, permission_sets_constantized
21
+ end
22
+
23
+ ::Spree::Role.prepend self
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ class PermissionSet < Spree::Base
5
+ has_many :role_permissions # rubocop:disable Rails/HasManyOrHasOneDependent
6
+ has_many :roles, through: :role_permissions
7
+ validates :name, :set, presence: true
8
+ scope :display_permissions, -> { where('name LIKE ?', '%Display') }
9
+ scope :management_permissions, -> { where('name LIKE ?', '%Management') }
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A Role Manager has all the access of a UserManager and the ability to manage Roles
4
+ module Spree
5
+ module PermissionSets
6
+ class RoleManagement < PermissionSets::Base
7
+ def activate!
8
+ can [
9
+ :admin,
10
+ :display,
11
+ :create,
12
+ :update,
13
+ :save_in_address_book,
14
+ :remove_from_address_book,
15
+ :addresses,
16
+ :orders,
17
+ :items
18
+ ],
19
+ Spree.user_class
20
+
21
+ # due to how cancancan filters by associations,
22
+ # we have to define this twice, once for `accessible_by`
23
+ can :update_email, Spree.user_class, spree_roles: { id: nil }
24
+ # and once for `can?`
25
+ can :update_email, Spree.user_class do |user|
26
+ user.spree_roles.none?
27
+ end
28
+
29
+ cannot [:delete, :destroy], Spree.user_class
30
+ can :manage, Spree::StoreCredit
31
+ can :manage, Spree::Role
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ class RolePermission < Spree::Base
5
+ belongs_to :role
6
+ belongs_to :permission_set
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ Deface::Override.new(
4
+ virtual_path: 'spree/admin/shared/_menu',
5
+ name: 'add_user_roles_menu_links',
6
+ insert_bottom: "[data-hook='admin_tabs']"
7
+ ) do
8
+ <<-HTML
9
+ <% if can? :admin, Spree::Role %>
10
+ <%= tab(:roles, icon: 'users') %>
11
+ <% end %>
12
+ HTML
13
+ end
@@ -0,0 +1,38 @@
1
+ <div data-hook="admin_role_form_fields">
2
+ <div class="row">
3
+ <div class="col-4">
4
+ <%= f.field_container :name do %>
5
+ <%= f.label :name, class: 'required' %>
6
+ <%= f.text_field :name, class: 'fullwidth title' %>
7
+ <%= f.error_message_on :name %>
8
+ <% end %>
9
+ </div>
10
+ </div>
11
+
12
+ <div class="row">
13
+ <div class="left col-6">
14
+ <%= f.label nil, I18n.t("spree.display_permissions") %>
15
+ <ul style="list-style-type: none; padding: 0; margin: 0;">
16
+ <% Spree::PermissionSet.display_permissions.each do |permission| %>
17
+ <li>
18
+ <%= f.check_box 'permission_set_ids', {checked: f.object.try(:permission_sets).include?(permission), multiple: true}, permission.id, nil %>
19
+ <strong><%= permission.name %></strong>
20
+ </li>
21
+ <% end %>
22
+ </ul>
23
+ </div>
24
+ <div class="right col-6">
25
+ <%= f.label nil, I18n.t("spree.display_permissions") %>
26
+ <ul style="list-style-type: none; padding: 0; margin: 0;">
27
+ <% Spree::PermissionSet.management_permissions.each do |permission| %>
28
+ <li>
29
+ <%= f.check_box 'permission_set_ids', {checked: f.object.try(:permission_sets).include?(permission), multiple: true}, permission.id, nil %>
30
+ <strong><%= permission.name %></strong>
31
+ </li>
32
+ <% end %>
33
+ </ul>
34
+ </div>
35
+ </div>
36
+ </div>
37
+ <div class="clear"></div>
38
+ </div>
@@ -0,0 +1,19 @@
1
+ <% content_for :page_title do %>
2
+ <%= I18n.t("spree.editing_user_role") %>
3
+ <% end %>
4
+
5
+ <% content_for :page_actions do %>
6
+ <li>
7
+ <%= link_to I18n.t("spree.back_to_roles_list"), spree.admin_roles_path, :icon => 'arrow-left', class: "btn btn-primary" %>
8
+ </li>
9
+ <% end %>
10
+
11
+ <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @role } %>
12
+
13
+ <%= form_for [:admin, @role] do |f| %>
14
+ <fieldset class="no-border-top">
15
+ <%= render :partial => 'form', :locals => { :f => f } %>
16
+ <div class="clear"></div>
17
+ <%= render :partial => 'spree/admin/shared/edit_resource_links' %>
18
+ </fieldset>
19
+ <% end %>
@@ -0,0 +1,54 @@
1
+ <% content_for :page_title do %>
2
+ <%= I18n.t("spree.user_roles") %>
3
+ <% end %>
4
+
5
+ <% content_for :page_actions do %>
6
+ <% if can?(:admin, Spree::Role) && can?(:create, Spree::Role) %>
7
+ <li>
8
+ <%= link_to I18n.t("spree.new_user_role"), new_admin_role_url, :icon => 'plus', :id => 'admin_new_role_link', class: "btn btn-primary" %>
9
+ </li>
10
+ <% end %>
11
+ <% end %>
12
+
13
+ <% if @roles.non_base_roles.any? %>
14
+ <table class="index">
15
+ <colgroup>
16
+ <col style="width: 50%">
17
+ <col style="width: 50%">
18
+ </colgroup>
19
+ <thead>
20
+ <tr data-hook="role_header">
21
+ <th><%= I18n.t("spree.name") %></th>
22
+ <th><%= I18n.t("spree.permissions") %></th>
23
+ <th class="actions"></th>
24
+ </tr>
25
+ </thead>
26
+ <tbody>
27
+ <% @roles.non_base_roles.each do |role|%>
28
+ <tr id="<%= spree_dom_id role %>" data-hook="rate_row" class="<%= cycle('odd', 'even')%>">
29
+ <td class="align-center"><%=role.try(:name) || I18n.t("spree.not_available") %></td>
30
+ <td class="align-center"><%= role.permission_sets.map(&:name).to_sentence %></td>
31
+ <td class="actions">
32
+ <% if can?(:update, role) %>
33
+ <%= link_to_edit role, :no_text => true %>
34
+ <% end %>
35
+ <% if can?(:destroy, role) %>
36
+ <%= link_to_delete role, :no_text => true %>
37
+ <% end %>
38
+ </td>
39
+ </tr>
40
+ <% end %>
41
+ </tbody>
42
+ </table>
43
+ <% else %>
44
+ <div class="content row">
45
+ <div class="content col-12">
46
+ <div class= "no-objects-found">
47
+ <%= I18n.t("spree.no_resource_found", resource: I18n.t(:other, scope: 'activerecord.models.spree/role')) %>
48
+ <% if can?(:admin, Spree::Role) && can?(:create, Spree::Role) %>
49
+ <%= link_to I18n.t("spree.add_one"), spree.new_admin_role_path %>!
50
+ <% end %>
51
+ </div>
52
+ </div>
53
+ </div>
54
+ <% end %>
@@ -0,0 +1,23 @@
1
+ <% content_for :page_title do %>
2
+ <%= I18n.t("spree.new_user_role") %>
3
+ <% end %>
4
+
5
+ <% content_for :page_actions do %>
6
+ <li>
7
+ <%= link_to I18n.t("spree.back_to_roles_list"), spree.admin_roles_path, :icon => 'arrow-left', class: 'btn btn-primary' %>
8
+ </li>
9
+ <% end %>
10
+
11
+ <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @role } %>
12
+
13
+ <%= form_for [:admin, @role] do |f| %>
14
+ <fieldset class="no-border-top">
15
+
16
+ <%= render :partial => 'form', :locals => { :f => f } %>
17
+
18
+ <div class="clear"></div>
19
+
20
+ <%= render :partial => 'spree/admin/shared/new_resource_links' %>
21
+
22
+ </fieldset>
23
+ <% end %>
data/bin/console ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require "bundler/setup"
6
+ require "solidus_user_roles"
7
+
8
+ # You can add fixtures and/or initialization code here to make experimenting
9
+ # with your gem easier. You can also use a different console, if you like.
10
+ $LOAD_PATH.unshift(*Dir["#{__dir__}/../app/*"])
11
+
12
+ # (If you use this, don't forget to add pry to your Gemfile!)
13
+ # require "pry"
14
+ # Pry.start
15
+
16
+ require "irb"
17
+ IRB.start(__FILE__)
data/bin/rails ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if %w[g generate].include? ARGV.first
4
+ exec "#{__dir__}/rails-engine", *ARGV
5
+ else
6
+ exec "#{__dir__}/rails-sandbox", *ARGV
7
+ end
data/bin/rails-engine ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('..', __dir__)
6
+ ENGINE_PATH = File.expand_path('../lib/solidus_user_roles/engine', __dir__)
7
+
8
+ # Set up gems listed in the Gemfile.
9
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
10
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
11
+
12
+ require 'rails/all'
13
+ require 'rails/engine/commands'
data/bin/rails-sandbox ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ app_root = 'sandbox'
4
+
5
+ unless File.exist? "#{app_root}/bin/rails"
6
+ warn 'Creating the sandbox app...'
7
+ Dir.chdir "#{__dir__}/.." do
8
+ system "#{__dir__}/sandbox" or begin
9
+ warn 'Automatic creation of the sandbox app failed'
10
+ exit 1
11
+ end
12
+ end
13
+ end
14
+
15
+ Dir.chdir app_root
16
+ exec 'bin/rails', *ARGV
data/bin/rake ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "rubygems"
5
+ require "bundler/setup"
6
+
7
+ load Gem.bin_path("rake", "rake")