mks_auth 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +37 -0
- data/app/assets/config/mks_auth_manifest.js +2 -0
- data/app/assets/javascripts/mks_auth/application.js +13 -0
- data/app/assets/stylesheets/mks_auth/application.css +15 -0
- data/app/controllers/mks/auth/access_controller.rb +51 -0
- data/app/controllers/mks/auth/application_controller.rb +25 -0
- data/app/controllers/mks/auth/application_modules_controller.rb +60 -0
- data/app/controllers/mks/auth/user_roles_controller.rb +52 -0
- data/app/controllers/mks/auth/users_controller.rb +67 -0
- data/app/helpers/mks/auth/access_helper.rb +47 -0
- data/app/helpers/mks/auth/application_helper.rb +10 -0
- data/app/jobs/mks_auth/application_job.rb +4 -0
- data/app/mailers/mks_auth/application_mailer.rb +6 -0
- data/app/models/mks/auth/application_module.rb +13 -0
- data/app/models/mks/auth/application_record.rb +7 -0
- data/app/models/mks/auth/menu.rb +12 -0
- data/app/models/mks/auth/user.rb +24 -0
- data/app/models/mks/auth/user_role.rb +11 -0
- data/config/routes.rb +32 -0
- data/db/migrate/20161029065810_create_mks_auth_application_modules.rb +10 -0
- data/db/migrate/20161029065959_create_mks_auth_users.rb +16 -0
- data/db/migrate/20161029070807_create_mks_auth_user_roles.rb +9 -0
- data/db/migrate/20161029071047_create_mks_users_user_roles.rb +11 -0
- data/db/migrate/20161029072256_create_mks_auth_menus.rb +17 -0
- data/db/migrate/20161029074023_create_mks_menus_user_roles.rb +11 -0
- data/lib/mks/auth.rb +4 -0
- data/lib/mks/auth/engine.rb +28 -0
- data/lib/mks/auth/version.rb +5 -0
- data/lib/mks_auth.rb +2 -0
- data/lib/tasks/mks_auth_tasks.rake +4 -0
- data/spec/controllers/mks/auth/users_controller_spec.rb +20 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +5 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +34 -0
- data/spec/dummy/bin/update +29 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +9 -0
- data/spec/dummy/config/database.yml +23 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +54 -0
- data/spec/dummy/config/environments/production.rb +86 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/new_framework_defaults.rb +24 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/puma.rb +47 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/db/schema.rb +75 -0
- data/spec/dummy/log/development.log +3 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/application_modules.rb +6 -0
- data/spec/factories/menus.rb +10 -0
- data/spec/factories/user_roles.rb +17 -0
- data/spec/factories/users.rb +28 -0
- data/spec/models/mks/auth/application_module_spec.rb +36 -0
- data/spec/models/mks/auth/menu_spec.rb +16 -0
- data/spec/models/mks/auth/user_role_spec.rb +32 -0
- data/spec/models/mks/auth/user_spec.rb +46 -0
- data/spec/rails_helper.rb +57 -0
- data/spec/spec_helper.rb +109 -0
- data/spec/support/factory_girl.rb +5 -0
- metadata +302 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
+
# You can use `rails secret` to generate a secure secret key.
|
9
|
+
|
10
|
+
# Make sure the secrets in this file are kept private
|
11
|
+
# if you're sharing your code publicly.
|
12
|
+
|
13
|
+
development:
|
14
|
+
secret_key_base: a147d8742d0fabe6fadd0ba07f6807b0d524a5db9d753accb965980f1ba33deeedff53189388c7eef0b5f6f4783f0ef8d34fb54f0d77251e5cb19768b9995883
|
15
|
+
|
16
|
+
test:
|
17
|
+
secret_key_base: 593572d565a303a7a8b482733d58d1dc157e1b4df65110e73955745164f91305810fb25e31dcdbc24e1a0490b3f3e8fcaba85a35dc0806bf28c9861bf05d7d1a
|
18
|
+
|
19
|
+
# Do not keep production secrets in the repository,
|
20
|
+
# instead read values from the environment.
|
21
|
+
production:
|
22
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# Note that this schema.rb definition is the authoritative source for your
|
6
|
+
# database schema. If you need to create the application database on another
|
7
|
+
# system, you should be using db:schema:load, not running all the migrations
|
8
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
9
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
10
|
+
#
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema.define(version: 20161029074023) do
|
14
|
+
|
15
|
+
# These are extensions that must be enabled in order to support this database
|
16
|
+
enable_extension "plpgsql"
|
17
|
+
|
18
|
+
create_table "mks_auth_application_modules", force: :cascade do |t|
|
19
|
+
t.string "code", null: false
|
20
|
+
t.string "name", null: false
|
21
|
+
t.datetime "created_at", null: false
|
22
|
+
t.datetime "updated_at", null: false
|
23
|
+
end
|
24
|
+
|
25
|
+
create_table "mks_auth_menus", force: :cascade do |t|
|
26
|
+
t.string "text", null: false
|
27
|
+
t.string "icon_cls"
|
28
|
+
t.string "class_name"
|
29
|
+
t.string "location"
|
30
|
+
t.integer "parent_id"
|
31
|
+
t.integer "application_module_id"
|
32
|
+
t.datetime "created_at", null: false
|
33
|
+
t.datetime "updated_at", null: false
|
34
|
+
t.index ["application_module_id"], name: "index_mks_auth_menus_on_application_module_id", using: :btree
|
35
|
+
t.index ["parent_id"], name: "index_mks_auth_menus_on_parent_id", using: :btree
|
36
|
+
end
|
37
|
+
|
38
|
+
create_table "mks_auth_menus_user_roles", force: :cascade do |t|
|
39
|
+
t.integer "menu_id"
|
40
|
+
t.integer "user_role_id"
|
41
|
+
t.index ["menu_id", "user_role_id"], name: "index_mks_auth_menus_user_roles_on_menu_id_and_user_role_id", using: :btree
|
42
|
+
end
|
43
|
+
|
44
|
+
create_table "mks_auth_user_roles", force: :cascade do |t|
|
45
|
+
t.string "name", null: false
|
46
|
+
t.datetime "created_at", null: false
|
47
|
+
t.datetime "updated_at", null: false
|
48
|
+
end
|
49
|
+
|
50
|
+
create_table "mks_auth_users", force: :cascade do |t|
|
51
|
+
t.string "first_name", null: false
|
52
|
+
t.string "last_name", null: false
|
53
|
+
t.string "email", null: false
|
54
|
+
t.boolean "active", default: true, null: false
|
55
|
+
t.integer "application_module_id"
|
56
|
+
t.string "password_digest"
|
57
|
+
t.datetime "created_at", null: false
|
58
|
+
t.datetime "updated_at", null: false
|
59
|
+
t.index ["application_module_id"], name: "index_mks_auth_users_on_application_module_id", using: :btree
|
60
|
+
end
|
61
|
+
|
62
|
+
create_table "mks_auth_users_user_roles", id: false, force: :cascade do |t|
|
63
|
+
t.integer "user_id"
|
64
|
+
t.integer "user_role_id"
|
65
|
+
t.index ["user_id", "user_role_id"], name: "index_mks_auth_users_user_roles_on_user_id_and_user_role_id", using: :btree
|
66
|
+
end
|
67
|
+
|
68
|
+
add_foreign_key "mks_auth_menus", "mks_auth_application_modules", column: "application_module_id"
|
69
|
+
add_foreign_key "mks_auth_menus", "mks_auth_menus", column: "parent_id"
|
70
|
+
add_foreign_key "mks_auth_menus_user_roles", "mks_auth_menus", column: "menu_id"
|
71
|
+
add_foreign_key "mks_auth_menus_user_roles", "mks_auth_user_roles", column: "user_role_id"
|
72
|
+
add_foreign_key "mks_auth_users", "mks_auth_application_modules", column: "application_module_id"
|
73
|
+
add_foreign_key "mks_auth_users_user_roles", "mks_auth_user_roles", column: "user_role_id"
|
74
|
+
add_foreign_key "mks_auth_users_user_roles", "mks_auth_users", column: "user_id"
|
75
|
+
end
|
@@ -0,0 +1,3 @@
|
|
1
|
+
DEPRECATION WARNING: ActiveSupport.halt_callback_chains_on_return_false= is deprecated and will be removed in Rails 5.2. (called from <top (required)> at /Users/henock/projects/rails/logistics/mks_auth/spec/dummy/config/initializers/new_framework_defaults.rb:21)
|
2
|
+
DEPRECATION WARNING: ActiveSupport.halt_callback_chains_on_return_false= is deprecated and will be removed in Rails 5.2. (called from <top (required)> at /Users/henock/projects/rails/logistics/mks_auth/spec/dummy/config/initializers/new_framework_defaults.rb:21)
|
3
|
+
DEPRECATION WARNING: ActiveSupport.halt_callback_chains_on_return_false= is deprecated and will be removed in Rails 5.2. (called from <top (required)> at /Users/henock/projects/rails/logistics/mks_auth/spec/dummy/config/initializers/new_framework_defaults.rb:21)
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/404.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/422.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :user_role, class: 'Mks::Auth::UserRole' do
|
3
|
+
name { FFaker::Name.name }
|
4
|
+
|
5
|
+
trait :with_menu do
|
6
|
+
after(:create) do |role|
|
7
|
+
role.menus << create(:menu, text: 'menu1')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
trait :with_menus do
|
12
|
+
after(:create) do |role|
|
13
|
+
role.menus = [create(:menu, text: 'menu1'), create(:menu, text: 'menu2'), create(:menu, text: 'menu3')]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :user, class: 'Mks::Auth::User' do
|
3
|
+
first_name { FFaker::Name.name }
|
4
|
+
last_name { FFaker::Name.name }
|
5
|
+
email { FFaker::Internet.email }
|
6
|
+
active true
|
7
|
+
password { FFaker::Internet.password(min_length=6) }
|
8
|
+
association :application_module
|
9
|
+
|
10
|
+
trait :with_role do
|
11
|
+
after(:create) do |user|
|
12
|
+
user.roles << create(:user_role, name: 'role1')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
trait :with_role_and_menus do
|
17
|
+
after(:create) do |user|
|
18
|
+
user.roles << create(:user_role, :with_menus)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
trait :with_roles do
|
23
|
+
after(:create) do |user|
|
24
|
+
user.roles = [create(:user_role, name: 'role1'), create(:user_role, name: 'role2'), create(:user_role, name: 'role3')]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
module Mks
|
4
|
+
module Auth
|
5
|
+
RSpec.describe ApplicationModule, type: :model do
|
6
|
+
it 'has a valid factory' do
|
7
|
+
expect(create(:application_module)).to be_valid
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'is invalid with no code' do
|
11
|
+
expect(build(:application_module, :code => nil)).not_to be_valid
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'is invalid with no name' do
|
15
|
+
expect(build(:application_module, :code => nil)).not_to be_valid
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'is invalid with duplicate code' do
|
19
|
+
am = create(:application_module)
|
20
|
+
expect(build(:application_module, :code => am.code)).not_to be_valid
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'can access users' do
|
24
|
+
am = create(:application_module)
|
25
|
+
2.times { create(:user, :application_module => am) }
|
26
|
+
expect(am.users.count).to eq 2
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'can access menus' do
|
30
|
+
am = create(:application_module)
|
31
|
+
2.times { create(:menu, :application_module => am) }
|
32
|
+
expect(am.menus.count).to eq 2
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
module Mks
|
4
|
+
module Auth
|
5
|
+
RSpec.describe Menu, type: :model do
|
6
|
+
it 'has a valid factory' do
|
7
|
+
expect(create(:menu)).to be_valid
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'can access user roles' do
|
11
|
+
m = create(:user_role, :with_menu).menus.first
|
12
|
+
expect(m.roles.count).to eq 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|