edgarj 0.01.12
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +23 -0
- data/Rakefile +40 -0
- data/app/assets/javascripts/edgarj/base.js +49 -0
- data/app/assets/javascripts/edgarj/menu.js +39 -0
- data/app/assets/javascripts/edgarj/operator_selection.js +133 -0
- data/app/assets/stylesheets/edgarj/base.css +304 -0
- data/app/assets/stylesheets/edgarj/menu.css +65 -0
- data/app/controllers/edgarj/authentication_mixin.rb.sample +30 -0
- data/app/controllers/edgarj/controller_mixin_common.rb +80 -0
- data/app/controllers/edgarj/controller_mixin_for_app.rb +71 -0
- data/app/controllers/edgarj/edgarj_controller.rb +535 -0
- data/app/controllers/edgarj/model_permissions_controller.rb +8 -0
- data/app/controllers/edgarj/permission_mixin.rb +84 -0
- data/app/controllers/edgarj/popup_controller.rb +128 -0
- data/app/controllers/edgarj/rescue_mixin.rb +37 -0
- data/app/controllers/edgarj/user_group_users_controller.rb +8 -0
- data/app/controllers/edgarj/user_groups_controller.rb +9 -0
- data/app/controllers/edgarj/user_groups_popup_controller.rb +8 -0
- data/app/helpers/edgarj/assoc_helper.rb +369 -0
- data/app/helpers/edgarj/common_helper.rb +37 -0
- data/app/helpers/edgarj/edgarj_helper.rb +20 -0
- data/app/helpers/edgarj/field_helper.rb +397 -0
- data/app/helpers/edgarj/form_drawer.rb +322 -0
- data/app/helpers/edgarj/list_drawer.rb +169 -0
- data/app/helpers/edgarj/menu_helper.rb +92 -0
- data/app/helpers/edgarj/model_permissions_helper.rb +9 -0
- data/app/helpers/edgarj/popup_helper.rb +40 -0
- data/app/helpers/edgarj/search_helper.rb +14 -0
- data/app/helpers/edgarj/sessions_helper.rb +9 -0
- data/app/helpers/edgarj/user_group_users_helper.rb +9 -0
- data/app/helpers/edgarj/user_groups_helper.rb +9 -0
- data/app/helpers/edgarj/user_groups_popup_helper.rb +9 -0
- data/app/models/edgarj/drawer/base.rb +234 -0
- data/app/models/edgarj/drawer/normal.rb +6 -0
- data/app/models/edgarj/drawer/popup.rb +47 -0
- data/app/models/edgarj/drawer.rb +13 -0
- data/app/models/edgarj/model_permission.rb +41 -0
- data/app/models/edgarj/page_info.rb +47 -0
- data/app/models/edgarj/search.rb +81 -0
- data/app/models/edgarj/search_form.rb +255 -0
- data/app/models/edgarj/search_popup.rb +44 -0
- data/app/models/edgarj/sssn.rb +120 -0
- data/app/models/edgarj/user_group.rb +67 -0
- data/app/models/edgarj/user_group_user.rb +18 -0
- data/app/models/edgarj.rb +5 -0
- data/app/views/edgarj/edgarj/_form.html.erb +25 -0
- data/app/views/edgarj/edgarj/_list.html.erb +52 -0
- data/app/views/edgarj/edgarj/_message_popup.html.erb +15 -0
- data/app/views/edgarj/edgarj/_search_form.html.erb +64 -0
- data/app/views/edgarj/edgarj/_search_operator.html.erb +17 -0
- data/app/views/edgarj/edgarj/_search_operator_selection.html.erb +12 -0
- data/app/views/edgarj/edgarj/clear.js.erb +1 -0
- data/app/views/edgarj/edgarj/create.js.erb +4 -0
- data/app/views/edgarj/edgarj/destroy.js.erb +2 -0
- data/app/views/edgarj/edgarj/index.html.erb +37 -0
- data/app/views/edgarj/edgarj/index.js.erb +1 -0
- data/app/views/edgarj/edgarj/message_popup.js.erb +3 -0
- data/app/views/edgarj/edgarj/page_info_save.js.erb +1 -0
- data/app/views/edgarj/edgarj/search.js.erb +4 -0
- data/app/views/edgarj/edgarj/search_clear.js.erb +1 -0
- data/app/views/edgarj/edgarj/show.js.erb +1 -0
- data/app/views/edgarj/edgarj/top.html.erb +4 -0
- data/app/views/edgarj/edgarj/update.js.erb +4 -0
- data/app/views/edgarj/popup/_index.html.erb +16 -0
- data/app/views/edgarj/popup/_list.html.erb +42 -0
- data/app/views/edgarj/popup/_message_popup.html.erb +15 -0
- data/app/views/edgarj/popup/_search.html.erb +42 -0
- data/app/views/edgarj/popup/_search_save_popup.html.erb +16 -0
- data/app/views/edgarj/popup/index.js.erb +5 -0
- data/app/views/edgarj/popup/message_popup.js.erb +3 -0
- data/app/views/edgarj/popup/page_info_save.js.erb +1 -0
- data/app/views/edgarj/popup/search.js.erb +15 -0
- data/app/views/edgarj/popup/view_status_save.js.erb +1 -0
- data/config/routes.rb +15 -0
- data/config/settings.yml +5 -0
- data/db/migrate/20131118084600_create_edgar_sssns.rb +14 -0
- data/db/migrate/20131123124730_create_edgar_page_infos.rb +15 -0
- data/db/migrate/20140116062252_create_edgar_user_groups.rb +18 -0
- data/db/migrate/20140116062327_create_edgar_user_group_users.rb +10 -0
- data/db/migrate/20140206222308_create_edgar_model_permissions.rb +14 -0
- data/db/migrate/20141209053055_rename_edgar_to_edgarj.rb +17 -0
- data/lib/core_ext/active_record.rb +123 -0
- data/lib/core_ext/resources.rb +71 -0
- data/lib/edgarj/engine.rb +64 -0
- data/lib/edgarj/enum_cache.rb +46 -0
- data/lib/edgarj/templates/rails/helper/helper.rb +10 -0
- data/lib/edgarj/templates/test_unit/scaffold/functional_test.rb +575 -0
- data/lib/edgarj/version.rb +3 -0
- data/lib/edgarj.rb +14 -0
- data/lib/generators/edgarj/popup_scaffold/USAGE +6 -0
- data/lib/generators/edgarj/popup_scaffold/popup_scaffold_generator.rb +35 -0
- data/lib/generators/edgarj/popup_scaffold/templates/controller.rb +13 -0
- data/lib/generators/edgarj/popup_scaffold/templates/functional_test.rb +197 -0
- data/lib/generators/edgarj/popup_scaffold/templates/helper.rb +9 -0
- data/lib/generators/edgarj/scaffold/USAGE +17 -0
- data/lib/generators/edgarj/scaffold/scaffold_generator.rb +40 -0
- data/lib/generators/edgarj/scaffold/templates/controller.rb +13 -0
- data/lib/tasks/edgarj_tasks.rake +32 -0
- data/lib/tasks/pakcage.rake +18 -0
- data/locale/en.yml +94 -0
- data/locale/ja.yml +100 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +21 -0
- data/test/dummy/app/assets/javascripts/authors.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +16 -0
- data/test/dummy/app/assets/stylesheets/authors.css +4 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/test/dummy/app/controllers/application_controller.rb +15 -0
- data/test/dummy/app/controllers/authors_controller.rb +6 -0
- data/test/dummy/app/controllers/authors_popup_controller.rb +6 -0
- data/test/dummy/app/controllers/books_controller.rb +6 -0
- data/test/dummy/app/controllers/dummy_auth_mixin.rb +36 -0
- data/test/dummy/app/decorators/models/edgarj/user_group_decorator.rb +1 -0
- data/test/dummy/app/helpers/application_helper.rb +3 -0
- data/test/dummy/app/helpers/authors_helper.rb +7 -0
- data/test/dummy/app/helpers/authors_popup_helper.rb +7 -0
- data/test/dummy/app/helpers/books_helper.rb +7 -0
- data/test/dummy/app/models/author.rb +32 -0
- data/test/dummy/app/models/book.rb +5 -0
- data/test/dummy/app/models/user.rb +13 -0
- data/test/dummy/app/views/layouts/application.html.erb +32 -0
- data/test/dummy/app/views/layouts/login.html.erb +20 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +15 -0
- data/test/dummy/config/edgarj/menu_config.rb +28 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +42 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +34 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/strong_parameter.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +26 -0
- data/test/dummy/config/routes.rb +60 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/migrate/20131107120635_create_authors.rb +9 -0
- data/test/dummy/db/migrate/20131218011851_create_books.rb +10 -0
- data/test/dummy/db/migrate/20140201000000_add_user_group_id_to_authors.rb +5 -0
- data/test/dummy/db/migrate/20140807065420_create_users.rb +10 -0
- data/test/dummy/db/schema.rb +93 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/functional/authors_controller_test.rb +631 -0
- data/test/dummy/test/functional/books_controller_test.rb +516 -0
- data/test/dummy/test/helpers/authors_helper_test.rb +4 -0
- data/test/dummy/test/unit/author_test.rb +7 -0
- data/test/dummy/test/unit/book_test.rb +7 -0
- data/test/edgar_test.rb +7 -0
- data/test/fixtures/authors.yml +32 -0
- data/test/fixtures/books.yml +56 -0
- data/test/fixtures/edgarj/model_permissions.yml +97 -0
- data/test/fixtures/edgarj/page_infos.yml +84 -0
- data/test/fixtures/edgarj/sssns.yml +38 -0
- data/test/fixtures/edgarj/user_group_users.yml +114 -0
- data/test/fixtures/edgarj/user_groups.yml +95 -0
- data/test/fixtures/users.yml +49 -0
- data/test/functional/edgarj/edgarj_controller_test.rb +24 -0
- data/test/functional/edgarj/model_permissions_controller_test.rb +554 -0
- data/test/functional/edgarj/user_group_users_controller_test.rb +567 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/support/edgarj/controller_supporter.rb +23 -0
- data/test/test_helper.rb +23 -0
- data/test/unit/edgarj/model_permission_test.rb +27 -0
- data/test/unit/edgarj/page_info_test.rb +7 -0
- data/test/unit/edgarj/sssn_test.rb +10 -0
- data/test/unit/edgarj/user_group_test.rb +32 -0
- data/test/unit/edgarj/user_group_user_test.rb +9 -0
- data/test/unit/helpers/edgarj/model_permissions_helper_test.rb +6 -0
- data/test/unit/helpers/edgarj/user_group_users_helper_test.rb +6 -0
- metadata +456 -0
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Edgarj
|
|
4
|
+
class ModelPermissionsControllerTest < ActionController::TestCase
|
|
5
|
+
context 'root user' do
|
|
6
|
+
setup do
|
|
7
|
+
login_as(:root)
|
|
8
|
+
@edgarj_model_permission = edgarj_model_permissions(:product_read_only)
|
|
9
|
+
@pi = create_page_info(@sssn, 'edgarj_model_permissions', Edgarj::ModelPermission)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
should 'get index' do
|
|
13
|
+
get :index
|
|
14
|
+
assert_response :success
|
|
15
|
+
assert_not_nil assigns(:list)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
should 'paginate' do
|
|
19
|
+
xhr :get, :index, page: 2
|
|
20
|
+
assert_response :success
|
|
21
|
+
assert_not_nil assigns(:list)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
should 'sort' do
|
|
25
|
+
xhr :put, :page_info_save,
|
|
26
|
+
id: @pi.id,
|
|
27
|
+
edgarj_page_info: {
|
|
28
|
+
dir: 'asc',
|
|
29
|
+
order_by: 'created_at'
|
|
30
|
+
}
|
|
31
|
+
assert_response :success
|
|
32
|
+
assert_not_nil assigns(:list)
|
|
33
|
+
assert_equal 'asc', assigns(:page_info).dir
|
|
34
|
+
assert_equal 'created_at', assigns(:page_info).order_by
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
should 'create edgarj_model_permission' do
|
|
38
|
+
assert_difference('Edgarj::ModelPermission.count') do
|
|
39
|
+
xhr :post, :create, edgarj_model_permission: {flags: 0}
|
|
40
|
+
end
|
|
41
|
+
assert_response :success
|
|
42
|
+
assert assigns(:record)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
should 'not create invalid edgarj_model_permission' do
|
|
46
|
+
skip 'not create invalid edgarj_model_permission'
|
|
47
|
+
assert_no_difference('Edgarj::ModelPermission.count') do
|
|
48
|
+
#xhr :post, :create, invalid resource attributes...
|
|
49
|
+
end
|
|
50
|
+
assert_response :success
|
|
51
|
+
assert assigns(:record)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
should 'show edgarj_model_permission in HTML' do
|
|
55
|
+
get :show, id: @edgarj_model_permission
|
|
56
|
+
assert_response :success
|
|
57
|
+
assert_not_nil assigns(:record)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
should 'show edgarj_model_permission in JS' do
|
|
61
|
+
xhr :get, :show, id: @edgarj_model_permission
|
|
62
|
+
assert_response :success
|
|
63
|
+
assert_not_nil assigns(:record)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
should 'update edgarj_model_permission' do
|
|
67
|
+
xhr :put, :update, id: @edgarj_model_permission, edgarj_model_permission: { }
|
|
68
|
+
assert_response :success
|
|
69
|
+
assert assigns(:record)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
should 'destroy edgarj_model_permission' do
|
|
73
|
+
assert_difference('Edgarj::ModelPermission.count', -1) do
|
|
74
|
+
xhr :delete, :destroy, id: @edgarj_model_permission
|
|
75
|
+
end
|
|
76
|
+
assert_response :success
|
|
77
|
+
assert assigns(:record)
|
|
78
|
+
assert assigns(:list)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
should 'clear edgarj_model_permission' do
|
|
82
|
+
assert_no_difference('Edgarj::ModelPermission.count') do
|
|
83
|
+
xhr :get, :clear
|
|
84
|
+
end
|
|
85
|
+
assert_response :success
|
|
86
|
+
assert_not_nil assigns(:record)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
should 'csv_download edgarj_model_permissions' do
|
|
90
|
+
get :csv_download
|
|
91
|
+
assert_response :success
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
should 'search' do
|
|
95
|
+
xhr :get, :search, edgarj_search_form: {}
|
|
96
|
+
assert_response :success
|
|
97
|
+
assert assigns(:list).count >= 1
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
should 'search_clear edgarj_model_permission' do
|
|
101
|
+
xhr :get, :search_clear
|
|
102
|
+
assert_response :success
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
should 'search_save edgarj_model_permission' do
|
|
106
|
+
skip 'search_save'
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
should 'search_load edgarj_model_permission' do
|
|
110
|
+
skip 'search_load'
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# All of tests in this context is skipped because it is required
|
|
115
|
+
# to prepare read-only user.
|
|
116
|
+
# When complete the preparation, delete the skip lines.
|
|
117
|
+
context 'read-only user' do
|
|
118
|
+
setup do
|
|
119
|
+
# prepare fixtures of model_permissions, user_groups, and
|
|
120
|
+
# user_group_users for read-only user of the
|
|
121
|
+
# Edgarj::ModelPermissionsController and login by him/her.
|
|
122
|
+
#
|
|
123
|
+
#login_as(:edgarj_model_permission_reader)
|
|
124
|
+
#@pi = create_page_info(@sssn, 'edgarj_model_permissions', Edgarj::ModelPermission)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
should 'get index' do
|
|
128
|
+
skip 'get index'
|
|
129
|
+
get :index
|
|
130
|
+
assert_response :success
|
|
131
|
+
assert_not_nil assigns(:list)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
should 'paginate' do
|
|
135
|
+
skip 'paginate'
|
|
136
|
+
xhr :get, :index, page: 2
|
|
137
|
+
assert_response :success
|
|
138
|
+
assert_not_nil assigns(:list)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
should 'sort' do
|
|
142
|
+
skip 'sort'
|
|
143
|
+
xhr :put, :page_info_save,
|
|
144
|
+
id: @pi.id,
|
|
145
|
+
edgarj_page_info: {
|
|
146
|
+
dir: 'asc',
|
|
147
|
+
order_by: 'created_at'
|
|
148
|
+
}
|
|
149
|
+
assert_response :success
|
|
150
|
+
assert_not_nil assigns(:list)
|
|
151
|
+
assert_equal 'asc', assigns(:page_info).dir
|
|
152
|
+
assert_equal 'created_at', assigns(:page_info).order_by
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
should 'not create edgarj_model_permission' do
|
|
156
|
+
skip 'not create edgarj_model_permission'
|
|
157
|
+
assert_no_difference('Edgarj::ModelPermission.count') do
|
|
158
|
+
xhr :post, :create, edgarj_model_permission: { }
|
|
159
|
+
end
|
|
160
|
+
assert_template 'message_popup'
|
|
161
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
should 'not create invalid edgarj_model_permission' do
|
|
165
|
+
skip 'not create invalid edgarj_model_permission'
|
|
166
|
+
assert_no_difference('Edgarj::ModelPermission.count') do
|
|
167
|
+
#xhr :post, :create, invalid resource attributes...
|
|
168
|
+
end
|
|
169
|
+
assert_template 'message_popup'
|
|
170
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
should 'show edgarj_model_permission in HTML' do
|
|
174
|
+
skip 'show edgarj_model_permission in HTML'
|
|
175
|
+
get :show, id: @edgarj_model_permission
|
|
176
|
+
assert_response :success
|
|
177
|
+
assert_not_nil assigns(:record)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
should 'show edgarj_model_permission in JS' do
|
|
181
|
+
skip 'show edgarj_model_permission in JS'
|
|
182
|
+
xhr :get, :show, id: @edgarj_model_permission
|
|
183
|
+
assert_response :success
|
|
184
|
+
assert_not_nil assigns(:record)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
should 'not update edgarj_model_permission' do
|
|
188
|
+
skip 'not update edgarj_model_permission'
|
|
189
|
+
xhr :put, :update, id: @edgarj_model_permission, edgarj_model_permission: { }
|
|
190
|
+
assert_template 'message_popup'
|
|
191
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
|
192
|
+
old_edgarj_model_permission = @edgarj_model_permission
|
|
193
|
+
assert_equal(
|
|
194
|
+
old_edgarj_model_permission,
|
|
195
|
+
@edgarj_model_permission.reload)
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
should 'not destroy edgarj_model_permission' do
|
|
199
|
+
skip 'not destroy edgarj_model_permission'
|
|
200
|
+
assert_no_difference('Edgarj::ModelPermission.count') do
|
|
201
|
+
xhr :delete, :destroy, id: @edgarj_model_permission
|
|
202
|
+
end
|
|
203
|
+
assert_template 'message_popup'
|
|
204
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
should 'clear edgarj_model_permission' do
|
|
208
|
+
skip 'clear edgarj_model_permission'
|
|
209
|
+
assert_no_difference('Edgarj::ModelPermission.count') do
|
|
210
|
+
xhr :get, :clear
|
|
211
|
+
end
|
|
212
|
+
assert_response :success
|
|
213
|
+
assert_not_nil assigns(:record)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
should 'csv_download edgarj_model_permissions' do
|
|
217
|
+
skip 'csv_download edgarj_model_permissions'
|
|
218
|
+
get :csv_download
|
|
219
|
+
assert_response :success
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
should 'search' do
|
|
223
|
+
skip 'search edgarj_model_permissions'
|
|
224
|
+
xhr :get, :search, edgarj_search_form: {}
|
|
225
|
+
assert_response :success
|
|
226
|
+
assert assigns(:list).count >= 1
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
should 'search_clear edgarj_model_permission' do
|
|
230
|
+
skip 'search_clear edgarj_model_permission'
|
|
231
|
+
xhr :get, :search_clear
|
|
232
|
+
assert_response :success
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
should 'search_save edgarj_model_permission' do
|
|
236
|
+
skip 'search_save'
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
should 'search_load edgarj_model_permission' do
|
|
240
|
+
skip 'search_load'
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
# All of tests in this context is skipped because it is required
|
|
245
|
+
# to prepare 'permitted but user_scoped' user.
|
|
246
|
+
# When complete the preparation, delete the skip lines.
|
|
247
|
+
context 'permitted and user_scoped user' do
|
|
248
|
+
setup do
|
|
249
|
+
# prepare fixtures of model_permissions, user_groups, and
|
|
250
|
+
# user_group_users for permitted and user_scoped user of the
|
|
251
|
+
# Edgarj::ModelPermissionsController and login by him/her.
|
|
252
|
+
#
|
|
253
|
+
#login_as(:permitted_n_user_scoped_on_edgarj_model_permissions)
|
|
254
|
+
#@pi = create_page_info(@sssn, 'edgarj_model_permissions', Edgarj::ModelPermission)
|
|
255
|
+
|
|
256
|
+
@edgarj_model_permission = edgarj_model_permissions(:product_read_only)
|
|
257
|
+
@edgarj_model_permission_scoped_out = edgarj_model_permissions(:book_admin)
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
should 'search 1 hit since role and user_scoped satisfy' do
|
|
261
|
+
skip 'search 1 hit since role and user_scoped satisfy'
|
|
262
|
+
xhr :get, :search, edgarj_search_form: {_id: @edgarj_model_permission.id}
|
|
263
|
+
assert_response :success
|
|
264
|
+
assert_equal 1, assigns(:list).count
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
should 'not search 1 hit since key is out-of-scope' do
|
|
268
|
+
skip 'not search 1 hit since key is out-of-scope'
|
|
269
|
+
xhr :get, :search, edgarj_search_form: {_id: @edgarj_model_permission_scoped_out.id}
|
|
270
|
+
assert_response :success
|
|
271
|
+
assert_equal 0, assigns(:list).count
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
should 'show assigned edgarj_model_permission in HTML' do
|
|
275
|
+
skip 'show assigned edgarj_model_permission in HTML'
|
|
276
|
+
get :show, id: @edgarj_model_permission
|
|
277
|
+
assert_response :success
|
|
278
|
+
assert_not_nil assigns(:record)
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
should 'show assigned edgarj_model_permission in JS' do
|
|
282
|
+
skip 'show assigned edgarj_model_permission in JS'
|
|
283
|
+
xhr :get, :show, id: @edgarj_model_permission
|
|
284
|
+
assert_response :success
|
|
285
|
+
assert_not_nil assigns(:record)
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
should 'not show non-assigned edgarj_model_permission in HTML' do
|
|
289
|
+
skip 'not show non-assigned edgarj_model_permission in HTML'
|
|
290
|
+
get :show, id: @edgarj_model_permission_scoped_out
|
|
291
|
+
assert_response :redirect
|
|
292
|
+
assert_nil assigns(:record)
|
|
293
|
+
assert_equal I18n.t('edgarj.default.not_found'), flash[:error]
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
should 'not show non-assigned edgarj_model_permission in JS' do
|
|
297
|
+
skip 'not show non-assigned edgarj_model_permission in JS'
|
|
298
|
+
xhr :get, :show, id: @edgarj_model_permission_scoped_out
|
|
299
|
+
assert_response :success
|
|
300
|
+
assert_nil assigns(:record)
|
|
301
|
+
assert_equal I18n.t('edgarj.default.not_found'), flash[:error]
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
should 'update edgarj_model_permission' do
|
|
305
|
+
skip 'update edgarj_model_permission'
|
|
306
|
+
xhr :put, :update, id: @edgarj_model_permission, edgarj_model_permission: { }
|
|
307
|
+
assert_response :success
|
|
308
|
+
assert assigns(:record)
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
should 'not update edgarj_model_permission' do
|
|
312
|
+
skip 'not update edgarj_model_permission'
|
|
313
|
+
xhr :put, :update, id: @edgarj_model_permission, edgarj_model_permission: { }
|
|
314
|
+
assert_nil assigns(:record)
|
|
315
|
+
assert_equal I18n.t('edgarj.default.not_found'), flash[:error]
|
|
316
|
+
old_edgarj_model_permission = @edgarj_model_permission
|
|
317
|
+
assert_equal(
|
|
318
|
+
old_edgarj_model_permission,
|
|
319
|
+
@edgarj_model_permission.reload)
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
should 'destroy edgarj_model_permission' do
|
|
323
|
+
skip 'destroy edgarj_model_permission'
|
|
324
|
+
assert_difference('Edgarj::ModelPermission.count', -1) do
|
|
325
|
+
xhr :delete, :destroy, id: @edgarj_model_permission
|
|
326
|
+
end
|
|
327
|
+
assert_response :success
|
|
328
|
+
assert assigns(:record)
|
|
329
|
+
assert assigns(:list)
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
should 'not destroy edgarj_model_permission' do
|
|
333
|
+
skip 'not destroy edgarj_model_permission'
|
|
334
|
+
assert_no_difference('Edgarj::ModelPermission.count') do
|
|
335
|
+
xhr :delete, :destroy, id: @edgarj_model_permission_scoped_out
|
|
336
|
+
end
|
|
337
|
+
assert_equal I18n.t('edgarj.default.not_found'), flash[:error]
|
|
338
|
+
end
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
context 'not-permitted user' do
|
|
342
|
+
setup do
|
|
343
|
+
login_as(:not_permitted)
|
|
344
|
+
@edgarj_model_permission = edgarj_model_permissions(:product_read_only)
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
should 'not get index' do
|
|
348
|
+
get :index
|
|
349
|
+
|
|
350
|
+
assert_redirected_to top_path
|
|
351
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
should 'not paginate' do
|
|
355
|
+
xhr :get, :index, page: 2
|
|
356
|
+
|
|
357
|
+
assert_template 'message_popup'
|
|
358
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
should 'not sort' do
|
|
362
|
+
xhr :put, :page_info_save,
|
|
363
|
+
id: edgarj_page_infos(:root_zip_address),
|
|
364
|
+
edgarj_page_info: {
|
|
365
|
+
dir: 'asc',
|
|
366
|
+
order_by: 'name'
|
|
367
|
+
}
|
|
368
|
+
assert_template 'message_popup'
|
|
369
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
should 'not create edgarj_model_permission' do
|
|
373
|
+
assert_no_difference('Edgarj::ModelPermission.count') do
|
|
374
|
+
xhr :post, :create, edgarj_model_permission: { }
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
assert_template 'message_popup'
|
|
378
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
should 'not show edgarj_model_permission in HTML' do
|
|
382
|
+
get :show, id: @edgarj_model_permission
|
|
383
|
+
assert_redirected_to top_path
|
|
384
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
should 'not show edgarj_model_permission in JS' do
|
|
388
|
+
xhr :get, :show, id: @edgarj_model_permission
|
|
389
|
+
|
|
390
|
+
assert_template 'message_popup'
|
|
391
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
should 'not update edgarj_model_permission' do
|
|
395
|
+
xhr :put, :update, id: @edgarj_model_permission, edgarj_model_permission: { }
|
|
396
|
+
assert_template 'message_popup'
|
|
397
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
|
398
|
+
old_edgarj_model_permission = @edgarj_model_permission
|
|
399
|
+
assert_equal(
|
|
400
|
+
old_edgarj_model_permission,
|
|
401
|
+
@edgarj_model_permission.reload)
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
should 'not destroy edgarj_model_permission' do
|
|
405
|
+
assert_no_difference('Edgarj::ModelPermission.count') do
|
|
406
|
+
xhr :delete, :destroy, id: @edgarj_model_permission
|
|
407
|
+
end
|
|
408
|
+
assert_template 'message_popup'
|
|
409
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
should 'not clear' do
|
|
413
|
+
assert_no_difference('Edgarj::ModelPermission.count') do
|
|
414
|
+
xhr :get, :clear
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
assert_template 'message_popup'
|
|
418
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
should 'not csv_download' do
|
|
422
|
+
get :csv_download
|
|
423
|
+
|
|
424
|
+
assert_redirected_to top_path
|
|
425
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
should 'not search' do
|
|
429
|
+
xhr :get, :search, edgarj_search_form: {_id: @edgarj_model_permission.id}
|
|
430
|
+
|
|
431
|
+
assert_template 'message_popup'
|
|
432
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
should 'not search_clear' do
|
|
436
|
+
xhr :get, :search_clear
|
|
437
|
+
|
|
438
|
+
assert_template 'message_popup'
|
|
439
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
|
440
|
+
end
|
|
441
|
+
|
|
442
|
+
should 'not search_save' do
|
|
443
|
+
skip 'search_save'
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
should 'not search_load' do
|
|
447
|
+
skip 'search_load'
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
# test Edgarj::AuthenticationMixin
|
|
451
|
+
|
|
452
|
+
should 'current_user' do
|
|
453
|
+
get :index
|
|
454
|
+
assert_equal users(:not_permitted), @controller.send(:current_user)
|
|
455
|
+
end
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
context 'not-login' do
|
|
459
|
+
setup do
|
|
460
|
+
@edgarj_model_permission = edgarj_model_permissions(:product_read_only)
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
should 'not get index' do
|
|
464
|
+
get :index
|
|
465
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
should 'not paginate' do
|
|
469
|
+
xhr :get, :index, page: 2
|
|
470
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
should 'not sort' do
|
|
474
|
+
xhr :put, :page_info_save,
|
|
475
|
+
# ensure what happens when not-login user puts with
|
|
476
|
+
# current edgarj_page_info-id
|
|
477
|
+
id: edgarj_page_infos(:root_zip_address),
|
|
478
|
+
edgarj_page_info: {
|
|
479
|
+
dir: 'asc',
|
|
480
|
+
order_by: 'name'
|
|
481
|
+
}
|
|
482
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
should 'not create edgarj_model_permission' do
|
|
486
|
+
assert_no_difference('Edgarj::ModelPermission.count') do
|
|
487
|
+
xhr :post, :create, edgarj_model_permission: { name: @edgarj_model_permission.name }
|
|
488
|
+
end
|
|
489
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
|
490
|
+
end
|
|
491
|
+
|
|
492
|
+
should 'not create edgarj_model_permission invalid' do
|
|
493
|
+
assert_no_difference('Edgarj::ModelPermission.count') do
|
|
494
|
+
xhr :post, :create, edgarj_model_permission: { name: nil }
|
|
495
|
+
end
|
|
496
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
|
497
|
+
end
|
|
498
|
+
|
|
499
|
+
should 'not show edgarj_model_permission in HTML' do
|
|
500
|
+
get :show, id: @edgarj_model_permission
|
|
501
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
should 'not show edgarj_model_permission in JS' do
|
|
505
|
+
xhr :get, :show, id: @edgarj_model_permission
|
|
506
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
|
507
|
+
end
|
|
508
|
+
|
|
509
|
+
should 'not update edgarj_model_permission' do
|
|
510
|
+
assert_no_difference('Edgarj::ModelPermission.count') do
|
|
511
|
+
xhr :put, :update, id: @edgarj_model_permission, edgarj_model_permission: { name: @edgarj_model_permission.name }
|
|
512
|
+
end
|
|
513
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
|
514
|
+
end
|
|
515
|
+
|
|
516
|
+
should 'not destroy edgarj_model_permission' do
|
|
517
|
+
assert_no_difference('Edgarj::ModelPermission.count') do
|
|
518
|
+
xhr :delete, :destroy, id: @edgarj_model_permission
|
|
519
|
+
end
|
|
520
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
|
521
|
+
end
|
|
522
|
+
|
|
523
|
+
should 'not clear' do
|
|
524
|
+
assert_no_difference('Edgarj::ModelPermission.count') do
|
|
525
|
+
xhr :get, :clear
|
|
526
|
+
end
|
|
527
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
|
528
|
+
end
|
|
529
|
+
|
|
530
|
+
should 'not csv_download' do
|
|
531
|
+
get :csv_download
|
|
532
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
should 'not search' do
|
|
536
|
+
xhr :get, :search, edgarj_search_form: {_id: edgarj_model_permissions(:product_read_only).id}
|
|
537
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
|
538
|
+
end
|
|
539
|
+
|
|
540
|
+
should 'not search_clear' do
|
|
541
|
+
xhr :get, :search_clear
|
|
542
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
|
543
|
+
end
|
|
544
|
+
|
|
545
|
+
should 'not search_save' do
|
|
546
|
+
skip 'search_save'
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
should 'not search_load' do
|
|
550
|
+
skip 'search_load'
|
|
551
|
+
end
|
|
552
|
+
end
|
|
553
|
+
end
|
|
554
|
+
end
|