strongbolt 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +33 -0
  3. data/.gitignore +18 -0
  4. data/.rspec +1 -0
  5. data/.ruby-gemset +1 -0
  6. data/.ruby-version +1 -0
  7. data/Gemfile +4 -0
  8. data/Gemfile.lock +130 -0
  9. data/LICENSE.txt +22 -0
  10. data/README.md +182 -0
  11. data/Rakefile +1 -0
  12. data/app/assets/javascripts/strongbolt.js +1 -0
  13. data/app/assets/javascripts/strongbolt/role-capabilities.js +80 -0
  14. data/app/controllers/strongbolt/capabilities_controller.rb +77 -0
  15. data/app/controllers/strongbolt/roles_controller.rb +92 -0
  16. data/app/controllers/strongbolt/security_controller.rb +8 -0
  17. data/app/controllers/strongbolt/user_groups_controller.rb +76 -0
  18. data/app/controllers/strongbolt/user_groups_users_controller.rb +35 -0
  19. data/app/controllers/strongbolt_controller.rb +2 -0
  20. data/app/views/strongbolt/_menu.html.erb +13 -0
  21. data/app/views/strongbolt/capabilities/index.html.erb +53 -0
  22. data/app/views/strongbolt/capabilities/show.html.erb +53 -0
  23. data/app/views/strongbolt/roles/_capabilities.html.erb +47 -0
  24. data/app/views/strongbolt/roles/_capability.html.erb +21 -0
  25. data/app/views/strongbolt/roles/_form.html.erb +12 -0
  26. data/app/views/strongbolt/roles/edit.html.erb +14 -0
  27. data/app/views/strongbolt/roles/index.html.erb +54 -0
  28. data/app/views/strongbolt/roles/new.html.erb +11 -0
  29. data/app/views/strongbolt/roles/show.html.erb +52 -0
  30. data/app/views/strongbolt/user_groups/_form.html.erb +12 -0
  31. data/app/views/strongbolt/user_groups/edit.html.erb +14 -0
  32. data/app/views/strongbolt/user_groups/index.html.erb +46 -0
  33. data/app/views/strongbolt/user_groups/new.html.erb +13 -0
  34. data/app/views/strongbolt/user_groups/show.html.erb +88 -0
  35. data/lib/generators/strongbolt/fix_generator.rb +23 -0
  36. data/lib/generators/strongbolt/indexes_generator.rb +19 -0
  37. data/lib/generators/strongbolt/install_generator.rb +29 -0
  38. data/lib/generators/strongbolt/templates/fix.rb +5 -0
  39. data/lib/generators/strongbolt/templates/indexes.rb +21 -0
  40. data/lib/generators/strongbolt/templates/migration.rb +73 -0
  41. data/lib/generators/strongbolt/templates/strongbolt.rb +45 -0
  42. data/lib/generators/strongbolt/views_generator.rb +26 -0
  43. data/lib/strongbolt.rb +219 -0
  44. data/lib/strongbolt/base.rb +7 -0
  45. data/lib/strongbolt/bolted.rb +125 -0
  46. data/lib/strongbolt/bolted_controller.rb +297 -0
  47. data/lib/strongbolt/capabilities_role.rb +15 -0
  48. data/lib/strongbolt/capability.rb +165 -0
  49. data/lib/strongbolt/configuration.rb +111 -0
  50. data/lib/strongbolt/controllers/url_helpers.rb +37 -0
  51. data/lib/strongbolt/engine.rb +44 -0
  52. data/lib/strongbolt/errors.rb +38 -0
  53. data/lib/strongbolt/generators/migration.rb +35 -0
  54. data/lib/strongbolt/helpers.rb +18 -0
  55. data/lib/strongbolt/rails/routes.rb +20 -0
  56. data/lib/strongbolt/role.rb +46 -0
  57. data/lib/strongbolt/roles_user_group.rb +15 -0
  58. data/lib/strongbolt/rspec.rb +29 -0
  59. data/lib/strongbolt/rspec/user.rb +90 -0
  60. data/lib/strongbolt/tenantable.rb +304 -0
  61. data/lib/strongbolt/user_abilities.rb +292 -0
  62. data/lib/strongbolt/user_group.rb +24 -0
  63. data/lib/strongbolt/user_groups_user.rb +16 -0
  64. data/lib/strongbolt/users_tenant.rb +12 -0
  65. data/lib/strongbolt/version.rb +3 -0
  66. data/lib/tasks/strongbolt_tasks.rake +29 -0
  67. data/spec/controllers/strongbolt/capabilities_controller_spec.rb +254 -0
  68. data/spec/controllers/strongbolt/roles_controller_spec.rb +228 -0
  69. data/spec/controllers/strongbolt/user_groups_controller_spec.rb +216 -0
  70. data/spec/controllers/strongbolt/user_groups_users_controller_spec.rb +69 -0
  71. data/spec/controllers/without_authorization_controller_spec.rb +20 -0
  72. data/spec/dummy/.rspec +2 -0
  73. data/spec/dummy/README.rdoc +28 -0
  74. data/spec/dummy/Rakefile +6 -0
  75. data/spec/dummy/app/assets/images/.keep +0 -0
  76. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  77. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  78. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  79. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  80. data/spec/dummy/app/controllers/posts_controller.rb +18 -0
  81. data/spec/dummy/app/controllers/test_controller.rb +3 -0
  82. data/spec/dummy/app/controllers/without_authorization_controller.rb +5 -0
  83. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  84. data/spec/dummy/app/mailers/.keep +0 -0
  85. data/spec/dummy/app/models/.keep +0 -0
  86. data/spec/dummy/app/models/concerns/.keep +0 -0
  87. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  88. data/spec/dummy/bin/bundle +3 -0
  89. data/spec/dummy/bin/rails +4 -0
  90. data/spec/dummy/bin/rake +4 -0
  91. data/spec/dummy/config.ru +4 -0
  92. data/spec/dummy/config/application.rb +29 -0
  93. data/spec/dummy/config/boot.rb +5 -0
  94. data/spec/dummy/config/database.yml +25 -0
  95. data/spec/dummy/config/environment.rb +5 -0
  96. data/spec/dummy/config/environments/development.rb +37 -0
  97. data/spec/dummy/config/environments/production.rb +78 -0
  98. data/spec/dummy/config/environments/test.rb +39 -0
  99. data/spec/dummy/config/initializers/assets.rb +8 -0
  100. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  101. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  102. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  103. data/spec/dummy/config/initializers/inflections.rb +16 -0
  104. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  105. data/spec/dummy/config/initializers/session_store.rb +3 -0
  106. data/spec/dummy/config/initializers/strongbolt.rb +32 -0
  107. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  108. data/spec/dummy/config/locales/en.yml +23 -0
  109. data/spec/dummy/config/routes.rb +12 -0
  110. data/spec/dummy/config/secrets.yml +22 -0
  111. data/spec/dummy/db/development.sqlite3 +0 -0
  112. data/spec/dummy/db/migrate/20150630212236_create_strongbolt_tables.rb +54 -0
  113. data/spec/dummy/db/migrate/20150630212251_create_strongbolt_tables_indexes.rb +21 -0
  114. data/spec/dummy/db/schema.rb +84 -0
  115. data/spec/dummy/db/test.sqlite3 +0 -0
  116. data/spec/dummy/lib/assets/.keep +0 -0
  117. data/spec/dummy/public/404.html +67 -0
  118. data/spec/dummy/public/422.html +67 -0
  119. data/spec/dummy/public/500.html +66 -0
  120. data/spec/dummy/public/favicon.ico +0 -0
  121. data/spec/fabricators/capability_fabricator.rb +4 -0
  122. data/spec/fabricators/role_fabricator.rb +9 -0
  123. data/spec/fabricators/user_fabricator.rb +3 -0
  124. data/spec/fabricators/user_group_fabricator.rb +9 -0
  125. data/spec/fixtures/application.rb +28 -0
  126. data/spec/fixtures/controllers.rb +5 -0
  127. data/spec/spec_helper.rb +89 -0
  128. data/spec/strongbolt/bolted_controller_spec.rb +706 -0
  129. data/spec/strongbolt/bolted_spec.rb +136 -0
  130. data/spec/strongbolt/capability_spec.rb +251 -0
  131. data/spec/strongbolt/configuration_spec.rb +119 -0
  132. data/spec/strongbolt/controllers/url_helpers_spec.rb +34 -0
  133. data/spec/strongbolt/helpers_spec.rb +43 -0
  134. data/spec/strongbolt/role_spec.rb +90 -0
  135. data/spec/strongbolt/tenantable_spec.rb +281 -0
  136. data/spec/strongbolt/user_abilities_spec.rb +509 -0
  137. data/spec/strongbolt/user_group_spec.rb +37 -0
  138. data/spec/strongbolt/users_tenant_spec.rb +36 -0
  139. data/spec/strongbolt_spec.rb +274 -0
  140. data/spec/support/controller_macros.rb +11 -0
  141. data/spec/support/db_setup.rb +134 -0
  142. data/spec/support/helpers.rb +62 -0
  143. data/spec/support/transactional_specs.rb +17 -0
  144. data/strongbolt.gemspec +32 -0
  145. metadata +407 -0
@@ -0,0 +1,21 @@
1
+ <div class="btn-group"
2
+ data-model="<%= key[:model] %>"
3
+ data-require-ownership=<%= key[:require_ownership] %>
4
+ data-require-tenant-access=<%= key[:require_tenant_access] %>>
5
+
6
+ <% Capability::Actions.each do |action| %>
7
+ <% if inherited_capability[action.to_sym] %>
8
+ <button type="button" disabled class="btn btn-xs btn-success" title="Inherited">
9
+ <%= action.capitalize %>
10
+ </button>
11
+ <% else %>
12
+ <button type="button"
13
+ data-action="<%= action %>"
14
+ data-granted="<%= capability[action.to_sym] %>"
15
+ class="btn btn-xs <%= capability[action.to_sym] ? "btn-success" : "btn-danger" %>">
16
+ <%= action.capitalize %>
17
+ </button>
18
+ <% end %>
19
+ <% end %>
20
+
21
+ </div>
@@ -0,0 +1,12 @@
1
+ <%= simple_form_for(@role,
2
+ as: "role",
3
+ url: params[:action].to_sym == :new ? roles_path : role_path(@role),
4
+ method: params[:action].to_sym == :new ? :post : :put) do |f| %>
5
+
6
+ <%= f.input :name %>
7
+ <%= f.input :parent_id, collection: Role.where.not(id: @role.id).order('parent_id IS NOT NULL', :parent_id, :name) %>
8
+ <%= f.input :description %>
9
+
10
+ <%= f.button :wrapped, class: 'btn-primary', value: 'Save' %>
11
+
12
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <%= render 'strongbolt/menu', current: 'roles' %>
2
+
3
+ <ul class='breadcrumb'>
4
+ <h2 style='text-align:left'>Security: Role <em><%= @role.name %></em></h2>
5
+ <li>
6
+ <%= link_to "Roles", roles_path %>
7
+ </li>
8
+ <li>
9
+ <%= link_to @role.name, role_path(@role) %>
10
+ </li>
11
+ <li class='active'>Edit</li>
12
+ </ul>
13
+
14
+ <%= render 'form' %>
@@ -0,0 +1,54 @@
1
+ <%= render 'strongbolt/menu', current: 'roles' %>
2
+
3
+ <ul class='breadcrumb'>
4
+ <h2 style='text-align:left'>Security: Roles</h2>
5
+ <li>Roles</li>
6
+ </ul>
7
+
8
+ <div class="pull-right">
9
+ <%= link_to "New Role", new_role_path, class: 'btn btn-default' %>
10
+ </div>
11
+ <div class="clearfix"></div>
12
+
13
+ <table class="table table-striped table-summary">
14
+
15
+ <thead>
16
+ <tr>
17
+ <th>Name</th>
18
+ <th>Inherits from</th>
19
+ <th>Description</th>
20
+ <th>Permissions</th>
21
+ <th>User Groups</th>
22
+ <th></th>
23
+ </tr>
24
+ </thead>
25
+
26
+ <tbody>
27
+
28
+ <% @roles.each do |role| %>
29
+
30
+ <tr>
31
+ <td><%= link_to role.name, role_path(role) %></td>
32
+ <td>
33
+ <% if role.parent.present? %>
34
+ <%= link_to role.parent.name, role_path(role.parent) %>
35
+ <% end %>
36
+ </td>
37
+ <td><%= role.description %></td>
38
+ <td><%= role.capabilities.size %></td>
39
+ <td><%= role.user_groups.size %></td>
40
+ <td align="right">
41
+ <%= link_to edit_role_path(role) do %>
42
+ <i class="fa fa-pencil"></i>
43
+ <% end %>
44
+ <%= link_to role_path(role), method: :delete, data: { confirm: "Do you confirm deleting #{role.name}?" }, class: "text-danger" do %>
45
+ <i class="fa fa-trash-o"></i>
46
+ <% end %>
47
+ </td>
48
+ </tr>
49
+
50
+ <% end %>
51
+
52
+ </tbody>
53
+
54
+ </table>
@@ -0,0 +1,11 @@
1
+ <%= render 'strongbolt/menu', current: 'roles' %>
2
+
3
+ <ul class='breadcrumb'>
4
+ <h2 style='text-align:left'>Security: New Role</h2>
5
+ <li>
6
+ <%= link_to "Roles", roles_path %>
7
+ </li>
8
+ <li class='active'>New Role</li>
9
+ </ul>
10
+
11
+ <%= render 'form' %>
@@ -0,0 +1,52 @@
1
+ <%= render 'strongbolt/menu', current: 'roles' %>
2
+
3
+ <ul class='breadcrumb'>
4
+ <h2 style='text-align:left'>Security: Role <em><%= @role.name %></em></h2>
5
+ <li>
6
+ <%= link_to "Roles", roles_path %>
7
+ </li>
8
+ <li class='active'><%= @role.name %></li>
9
+ </ul>
10
+
11
+ <div class="pull-right">
12
+ <%= link_to "Edit", edit_role_path(@role), :class => "btn btn-default" %>
13
+ <%= link_to "Delete", role_path(@role), :class => "btn btn-danger", method: :delete, :data => {:confirm => "Do you confirm deleting #{@role.name}"} %>
14
+ </div>
15
+
16
+ <p><%= @role.description %></p>
17
+
18
+ <% if @role.parent.present? %>
19
+ <p>Inherits from: <%= link_to @role.parent.name, role_path(@role.parent) %></p>
20
+ <% end %>
21
+
22
+ <h3>User Groups</h3>
23
+
24
+ <table class="table table-condensed table-summary table-without-thead">
25
+ <% @role.user_groups.each do |user_group| %>
26
+ <tr>
27
+ <td>
28
+ <%= link_to user_group.name, user_group_path(user_group) %>
29
+ </td>
30
+ <td><%= user_group.description %></td>
31
+ <td><%= user_group.users.size %> users</td>
32
+ </tr>
33
+ <% end %>
34
+ </table>
35
+
36
+ <% if @descendants.size > 0 %>
37
+ <h3>Inherited by</h3>
38
+
39
+ <table class="table table-condensed table-summary table-without-thead">
40
+ <% @descendants.each do |descendant| %>
41
+ <tr>
42
+ <td><%= link_to descendant.name, role_path(descendant) %></td>
43
+ <td><%= descendant.description %></td>
44
+ <td><%= descendant.user_groups.size %> user groups</td>
45
+ <tr>
46
+ <% end %>
47
+ </table>
48
+ <% end %>
49
+
50
+ <h3>Permissions</h3>
51
+
52
+ <%= render 'capabilities' %>
@@ -0,0 +1,12 @@
1
+ <%= simple_form_for(@user_group,
2
+ as: "user_group",
3
+ url: params[:action].to_sym == :new ? user_groups_path : user_group_path(@user_group),
4
+ method: params[:action].to_sym == :new ? :post : :put) do |f| %>
5
+
6
+ <%= f.input :name %>
7
+ <%= f.input :description %>
8
+
9
+ <%= f.association :roles, as: :check_boxes %>
10
+
11
+ <%= f.button :wrapped, class: 'btn-primary', value: 'Save' %>
12
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <%= render 'strongbolt/menu', current: 'user_groups' %>
2
+
3
+ <ul class='breadcrumb'>
4
+ <h2 style='text-align:left'>Security: User Group <em><%= @user_group.name %></em></h2>
5
+ <li>
6
+ <%= link_to "User Groups", user_groups_path %>
7
+ </li>
8
+ <li>
9
+ <%= link_to @user_group.name, user_group_path(@user_group) %>
10
+ </li>
11
+ <li class="active">Edit</li>
12
+ </ul>
13
+
14
+ <%= render 'form'%>
@@ -0,0 +1,46 @@
1
+ <%= render 'strongbolt/menu', current: 'user_groups' %>
2
+
3
+ <ul class='breadcrumb'>
4
+ <h2 style='text-align:left'>Security: User Groups</h2>
5
+ <li class='active'>User Groups</li>
6
+ </ul>
7
+
8
+ <div class="pull-right">
9
+ <%= link_to "New User Group", new_user_group_path, class: "btn btn-default" %>
10
+ </div>
11
+ <div class="clearfix"></div>
12
+
13
+ <table class="table table-summary table-striped">
14
+ <thead>
15
+ <tr>
16
+ <th>Name</th>
17
+ <th>Description</th>
18
+ <th>Roles</th>
19
+ <th>Users</th>
20
+ <th></th>
21
+ </tr>
22
+ </thead>
23
+
24
+ <tbody>
25
+ <% @user_groups.each do |user_group| %>
26
+
27
+ <tr>
28
+ <td>
29
+ <%= link_to user_group.name, user_group_path(user_group) %>
30
+ </td>
31
+ <td><%= user_group.description %></td>
32
+ <td><%= user_group.roles.size %></td>
33
+ <td><%= user_group.users.size %></td>
34
+ <td align="right">
35
+ <%= link_to edit_user_group_path(user_group) do %>
36
+ <i class="fa fa-pencil"></i>
37
+ <% end %>
38
+ <%= link_to user_group_path(user_group), method: :delete, data: { confirm: "Do you confirm deleting #{user_group.name}?" }, class: "text-danger" do %>
39
+ <i class="fa fa-trash-o"></i>
40
+ <% end %>
41
+ </td>
42
+ </tr>
43
+
44
+ <% end %>
45
+ </tbody>
46
+ </table>
@@ -0,0 +1,13 @@
1
+ <%= render 'strongbolt/menu', current: 'user_groups' %>
2
+
3
+ <ul class='breadcrumb'>
4
+ <h2 style='text-align:left'>Security: New User Group</h2>
5
+ <li>
6
+ <%= link_to "User Groups", user_groups_path %>
7
+ </li>
8
+ <li class='active'>
9
+ New
10
+ </li>
11
+ </ul>
12
+
13
+ <%= render 'form' %>
@@ -0,0 +1,88 @@
1
+ <%= render 'strongbolt/menu', current: 'user_groups' %>
2
+
3
+ <ul class='breadcrumb'>
4
+ <h2 style='text-align:left'>Security: User Group <em><%= @user_group.name %></em></h2>
5
+ <li>
6
+ <%= link_to "User Groups", user_groups_path %>
7
+ </li>
8
+ <li class='active'>
9
+ <%= @user_group.name %>
10
+ </li>
11
+ </ul>
12
+
13
+ <p>
14
+ <%= @user_group.description %>
15
+ </p>
16
+
17
+ <div class="pull-right">
18
+ <%= link_to "Edit", edit_user_group_path(@user_group), :class => "btn btn-default" %>
19
+ <%= link_to "Delete", user_group_path(@user_group), :class => "btn btn-danger", method: :delete, :data => {:confirm => "Do you confirm deleting #{@user_group.name}"} %>
20
+ </div>
21
+
22
+ <h3>Roles</h3>
23
+
24
+ <table class="table table-summary table-condensed table-without-thead">
25
+ <tbody>
26
+ <% @user_group.roles.each do |role| %>
27
+
28
+ <tr>
29
+ <td><%= link_to role.name, role_path(role) %></td>
30
+ <td><%= role.description %></td>
31
+ <td><%= role.capabilities.size %> permissions</td>
32
+ </tr>
33
+
34
+ <% end %>
35
+ </tbody>
36
+ </table>
37
+
38
+ <h3>Users</h3>
39
+
40
+ <table class="table table-summary table-striped">
41
+ <thead>
42
+ <tr>
43
+ <th>Email</th>
44
+ <th>Sign Up Date</th>
45
+ <th></th>
46
+ </tr>
47
+ </thead>
48
+
49
+ <tbody>
50
+ <% @user_group.users.order(:email).each do |user| %>
51
+
52
+ <tr>
53
+ <td><%= user.email %></td>
54
+ <td><%= l user.created_at %></td>
55
+ <td align="right">
56
+ <%= link_to(user_group_user_path(@user_group, user), method: :delete, class: 'text-danger') do %>
57
+ <i class="fa fa-times"></i>
58
+ <% end %>
59
+ </td>
60
+ </tr>
61
+
62
+ <% end %>
63
+ </tbody>
64
+ </table>
65
+
66
+
67
+ <%= form_tag user_group_users_path(@user_group) do %>
68
+
69
+ <div class="row">
70
+ <div class="col-sm-8">
71
+ <%= select_tag :id, options_for_select(@users.pluck(:email, :id)), :class => "form-control", :prompt => "Select an user..." %>
72
+ </div>
73
+ <div class="spacer visible-xs"></div>
74
+ <div class="col-sm-4">
75
+ <%= submit_tag "Add user", class: "btn btn-block btn-primary" %>
76
+ </div>
77
+ </div>
78
+
79
+ <div class="spacer"></div>
80
+
81
+ <% end %>
82
+
83
+
84
+
85
+
86
+
87
+
88
+
@@ -0,0 +1,23 @@
1
+ require "strongbolt/generators/migration"
2
+
3
+ module Strongbolt
4
+ module Generators
5
+ #
6
+ # Creates a migration to fix a has many through with users tenants problem
7
+ #
8
+ class FixGenerator < Rails::Generators::Base
9
+ include Strongbolt::Generators::Migration
10
+
11
+ source_root File.expand_path('../templates', __FILE__)
12
+
13
+ def copy_fix
14
+ unless Strongbolt::UsersTenant.primary_key.nil?
15
+ puts"Strongbolt::UsersTenant already has a primary key, no need to use the fix"
16
+ else
17
+ copy_migration "fix", "fix_strongbolt_users_tenants_id"
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ require "strongbolt/generators/migration"
2
+
3
+ module Strongbolt
4
+ module Generators
5
+ #
6
+ # Creates a migration to fix a has many through with users tenants problem
7
+ #
8
+ class IndexesGenerator < Rails::Generators::Base
9
+ include Strongbolt::Generators::Migration
10
+
11
+ source_root File.expand_path('../templates', __FILE__)
12
+
13
+ def copy_fix
14
+ copy_migration "indexes", "create_strongbolt_tables_indexes"
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,29 @@
1
+ require "strongbolt/generators/migration"
2
+
3
+ module Strongbolt
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ include Strongbolt::Generators::Migration
7
+
8
+ source_root File.expand_path('../templates', __FILE__)
9
+
10
+ def copy_migrations
11
+ copy_migration "migration", "create_strongbolt_tables"
12
+ end
13
+
14
+ def copy_initializer
15
+ # Laods all the application models
16
+ Rails.application.eager_load!
17
+ # Copy the file
18
+ copy_file "strongbolt.rb", "config/initializers/strongbolt.rb"
19
+ # Fill in the list of models of the application
20
+ gsub_file "config/initializers/strongbolt.rb", '%MODELS%',
21
+ ActiveRecord::Base.descendants
22
+ .reject { |m| m.name =~ /^Strongbolt::/ }
23
+ .map { |m| "'#{m.name}'" }
24
+ .join(", ")
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,5 @@
1
+ class FixStrongboltUsersTenantsId < ActiveRecord::Migration
2
+ def change
3
+ add_column :strongbolt_users_tenants, :id, :primary_key
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ class CreateStrongboltTablesIndexes < ActiveRecord::Migration
2
+ def change
3
+ add_index :strongbolt_roles, :parent_id
4
+ add_index :strongbolt_roles, :lft
5
+ add_index :strongbolt_roles, :rgt
6
+
7
+ add_index :strongbolt_user_groups_users, :user_group_id
8
+ add_index :strongbolt_user_groups_users, :user_id
9
+
10
+ add_index :strongbolt_roles_user_groups, :user_group_id
11
+ add_index :strongbolt_roles_user_groups, :role_id
12
+
13
+ add_index :strongbolt_capabilities_roles, :role_id
14
+ add_index :strongbolt_capabilities_roles, :capability_id
15
+
16
+ add_index :strongbolt_users_tenants, :user_id
17
+ add_index :strongbolt_users_tenants, :tenant_id
18
+ add_index :strongbolt_users_tenants, :type
19
+ add_index :strongbolt_users_tenants, [:tenant_id, :type]
20
+ end
21
+ end