edgarj 0.01.12
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.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,516 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class BooksControllerTest < ActionController::TestCase
|
4
|
+
context 'root' do
|
5
|
+
setup do
|
6
|
+
login_as(:root)
|
7
|
+
@book = books(:tacit_dimension)
|
8
|
+
pi = edgarj_page_infos(:root_books)
|
9
|
+
pi.record = Edgarj::SearchForm.new(Book, {})
|
10
|
+
pi.save!
|
11
|
+
end
|
12
|
+
|
13
|
+
should 'get index' do
|
14
|
+
get :index
|
15
|
+
assert_response :success
|
16
|
+
assert_not_nil assigns(:list)
|
17
|
+
end
|
18
|
+
|
19
|
+
should 'paginate' do
|
20
|
+
xhr :get, :index, page: 2
|
21
|
+
assert_response :success
|
22
|
+
assert_not_nil assigns(:list)
|
23
|
+
assert_equal 2, assigns(:page_info).page
|
24
|
+
end
|
25
|
+
|
26
|
+
should 'sort' do
|
27
|
+
xhr :put, :page_info_save,
|
28
|
+
id: edgarj_page_infos(:root_books).id,
|
29
|
+
edgarj_page_info: {
|
30
|
+
dir: 'asc',
|
31
|
+
order_by: 'name'
|
32
|
+
}
|
33
|
+
assert_response :success
|
34
|
+
assert_not_nil assigns(:list)
|
35
|
+
assert_equal 'asc', assigns(:page_info).dir
|
36
|
+
assert_equal 'name', assigns(:page_info).order_by
|
37
|
+
|
38
|
+
xhr :put, :page_info_save,
|
39
|
+
id: edgarj_page_infos(:root_books).id,
|
40
|
+
edgarj_page_info: {
|
41
|
+
dir: 'desc',
|
42
|
+
order_by: 'created_at'
|
43
|
+
}
|
44
|
+
assert_equal 'desc', assigns(:page_info).reload.dir
|
45
|
+
assert_equal 'created_at', assigns(:page_info).reload.order_by
|
46
|
+
end
|
47
|
+
|
48
|
+
should 'create book' do
|
49
|
+
assert_difference('Book.count') do
|
50
|
+
xhr :post, :create, book: { name: @book.name }
|
51
|
+
end
|
52
|
+
assert_response :success
|
53
|
+
assert assigns(:record)
|
54
|
+
end
|
55
|
+
|
56
|
+
should 'not create invalid book' do
|
57
|
+
assert_no_difference('Book.count') do
|
58
|
+
xhr :post, :create, book: { name: nil }
|
59
|
+
end
|
60
|
+
assert_response :success
|
61
|
+
assert assigns(:record)
|
62
|
+
end
|
63
|
+
|
64
|
+
should 'show book in HTML' do
|
65
|
+
get :show, id: @book
|
66
|
+
assert_response :success
|
67
|
+
assert_not_nil assigns(:record)
|
68
|
+
end
|
69
|
+
|
70
|
+
should 'show book in JS' do
|
71
|
+
xhr :get, :show, id: @book
|
72
|
+
assert_response :success
|
73
|
+
assert_not_nil assigns(:record)
|
74
|
+
end
|
75
|
+
|
76
|
+
should 'update book' do
|
77
|
+
assert_no_difference('Book.count') do
|
78
|
+
xhr :put, :update, id: @book, book: { name: 'X' }
|
79
|
+
end
|
80
|
+
assert_response :success
|
81
|
+
assert assigns(:record)
|
82
|
+
assert_equal 'X', @book.reload.name
|
83
|
+
end
|
84
|
+
|
85
|
+
should 'destroy book' do
|
86
|
+
assert_difference('Book.count', -1) do
|
87
|
+
xhr :delete, :destroy, id: @book
|
88
|
+
end
|
89
|
+
assert_response :success
|
90
|
+
assert assigns(:record)
|
91
|
+
assert assigns(:list)
|
92
|
+
end
|
93
|
+
|
94
|
+
should 'clear' do
|
95
|
+
assert_no_difference('Book.count') do
|
96
|
+
xhr :get, :clear
|
97
|
+
end
|
98
|
+
assert_response :success
|
99
|
+
assert_not_nil assigns(:record)
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'search' do
|
103
|
+
should 'search' do
|
104
|
+
xhr :get, :search, edgarj_search_form: {_id: @book.id}
|
105
|
+
assert_response :success
|
106
|
+
assert_equal 1, assigns(:list).count
|
107
|
+
end
|
108
|
+
|
109
|
+
should 'search with operator' do
|
110
|
+
xhr :get, :search, edgarj_search_form: {_id: @book.id},
|
111
|
+
edgarj_search_form: {
|
112
|
+
edgarj_search_form_operator: {
|
113
|
+
_id: '<>'
|
114
|
+
}
|
115
|
+
}
|
116
|
+
assert_response :success
|
117
|
+
assert assigns(:list).count > 1
|
118
|
+
end
|
119
|
+
|
120
|
+
should 'not search by invalid condition' do
|
121
|
+
xhr :get, :search, edgarj_search_form: {_id: 'a'}
|
122
|
+
assert_response :success
|
123
|
+
assert ((l = assigns(:list))== nil || l.count == 0)
|
124
|
+
assert !assigns(:search).valid?
|
125
|
+
end
|
126
|
+
|
127
|
+
should 'search_clear' do
|
128
|
+
xhr :get, :search_clear
|
129
|
+
assert_response :success
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# test Edgarj::AuthenticationMixin
|
134
|
+
|
135
|
+
should 'current_user' do
|
136
|
+
get :index
|
137
|
+
assert_equal users(:root), @controller.send(:current_user)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
context 'read-only user' do
|
142
|
+
setup do
|
143
|
+
login_as(:book_reader)
|
144
|
+
@book = books(:tacit_dimension)
|
145
|
+
pi = edgarj_page_infos(:book_reader_books)
|
146
|
+
pi.record = Edgarj::SearchForm.new(Book, {})
|
147
|
+
pi.save!
|
148
|
+
end
|
149
|
+
|
150
|
+
should "get index" do
|
151
|
+
get :index
|
152
|
+
assert_response :success
|
153
|
+
assert_not_nil assigns(:list)
|
154
|
+
end
|
155
|
+
|
156
|
+
should "paginate" do
|
157
|
+
xhr :get, :index, page: 2
|
158
|
+
assert_response :success
|
159
|
+
assert_not_nil assigns(:list)
|
160
|
+
end
|
161
|
+
|
162
|
+
should "sort" do
|
163
|
+
xhr :put, :page_info_save,
|
164
|
+
id: edgarj_page_infos(:book_reader_books).id,
|
165
|
+
edgarj_page_info: {
|
166
|
+
dir: 'asc',
|
167
|
+
order_by: 'name'
|
168
|
+
}
|
169
|
+
assert_response :success
|
170
|
+
assert_not_nil assigns(:list)
|
171
|
+
assert_equal 'asc', assigns(:page_info).dir
|
172
|
+
assert_equal 'name', assigns(:page_info).order_by
|
173
|
+
end
|
174
|
+
|
175
|
+
should "not create book" do
|
176
|
+
assert_no_difference('Book.count') do
|
177
|
+
xhr :post, :create, book: { name: @book.name }
|
178
|
+
end
|
179
|
+
assert_template 'message_popup'
|
180
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
181
|
+
end
|
182
|
+
|
183
|
+
should "not create book invalid" do
|
184
|
+
assert_no_difference('Book.count') do
|
185
|
+
xhr :post, :create, book: { name: nil }
|
186
|
+
end
|
187
|
+
assert_template 'message_popup'
|
188
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
189
|
+
end
|
190
|
+
|
191
|
+
should "show book in HTML" do
|
192
|
+
get :show, id: @book
|
193
|
+
assert_response :success
|
194
|
+
assert_not_nil assigns(:record)
|
195
|
+
end
|
196
|
+
|
197
|
+
should "show book in JS" do
|
198
|
+
xhr :get, :show, id: @book
|
199
|
+
assert_response :success
|
200
|
+
assert_not_nil assigns(:record)
|
201
|
+
end
|
202
|
+
|
203
|
+
should "not update book" do
|
204
|
+
assert_no_difference('Book.count') do
|
205
|
+
xhr :put, :update, id: @book, book: { name: 'X' }
|
206
|
+
end
|
207
|
+
assert_template 'message_popup'
|
208
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
209
|
+
assert_not_equal 'X', @book.reload.name
|
210
|
+
end
|
211
|
+
|
212
|
+
should "not destroy book" do
|
213
|
+
assert_no_difference('Book.count') do
|
214
|
+
xhr :delete, :destroy, id: @book
|
215
|
+
end
|
216
|
+
assert_template 'message_popup'
|
217
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
218
|
+
end
|
219
|
+
|
220
|
+
# additional routes tests
|
221
|
+
|
222
|
+
should "clear" do
|
223
|
+
assert_no_difference('Book.count') do
|
224
|
+
xhr :get, :clear
|
225
|
+
end
|
226
|
+
assert_response :success
|
227
|
+
assert_not_nil assigns(:record)
|
228
|
+
end
|
229
|
+
|
230
|
+
should "csv_download" do
|
231
|
+
get :csv_download
|
232
|
+
assert_response :success
|
233
|
+
end
|
234
|
+
|
235
|
+
|
236
|
+
should 'search' do
|
237
|
+
xhr :get, :search, edgarj_search_form: {_id: books(:tacit_dimension).id}
|
238
|
+
assert_response :success
|
239
|
+
assert_equal 1, assigns(:list).count
|
240
|
+
end
|
241
|
+
|
242
|
+
should 'search_clear' do
|
243
|
+
xhr :get, :search_clear
|
244
|
+
assert_response :success
|
245
|
+
end
|
246
|
+
|
247
|
+
should 'search_save' do
|
248
|
+
skip 'search_save'
|
249
|
+
end
|
250
|
+
|
251
|
+
should 'search_load' do
|
252
|
+
skip 'search_load'
|
253
|
+
end
|
254
|
+
|
255
|
+
=begin
|
256
|
+
should 'zip_complete' do
|
257
|
+
xhr :get, :zip_complete,
|
258
|
+
zip: '1000000',
|
259
|
+
adrs_prefix: :book_adrs_attributes_
|
260
|
+
assert_response :success
|
261
|
+
assert_equal 'Tokyo', assigns(:address).prefecture
|
262
|
+
end
|
263
|
+
=end
|
264
|
+
|
265
|
+
# test Edgarj::AuthenticationMixin
|
266
|
+
|
267
|
+
should 'current_user' do
|
268
|
+
get :index
|
269
|
+
|
270
|
+
assert_equal users(:book_reader), @controller.send(:current_user)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
context 'not-permitted user' do
|
275
|
+
setup do
|
276
|
+
login_as(:not_permitted)
|
277
|
+
@book = books(:tacit_dimension)
|
278
|
+
end
|
279
|
+
|
280
|
+
should "not get index" do
|
281
|
+
get :index
|
282
|
+
assert_redirected_to top_path
|
283
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
284
|
+
end
|
285
|
+
|
286
|
+
should "not paginate" do
|
287
|
+
xhr :get, :index, page: 2
|
288
|
+
assert_template 'message_popup'
|
289
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
290
|
+
end
|
291
|
+
|
292
|
+
should "not sort" do
|
293
|
+
xhr :put, :page_info_save,
|
294
|
+
id: edgarj_page_infos(:book_reader_books).id,
|
295
|
+
edgarj_page_info: {
|
296
|
+
dir: 'asc',
|
297
|
+
order_by: 'name'
|
298
|
+
}
|
299
|
+
assert_template 'message_popup'
|
300
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
301
|
+
end
|
302
|
+
|
303
|
+
should "not create book" do
|
304
|
+
assert_no_difference('Book.count') do
|
305
|
+
xhr :post, :create, book: { name: @book.name }
|
306
|
+
end
|
307
|
+
assert_template 'message_popup'
|
308
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
309
|
+
end
|
310
|
+
|
311
|
+
should "not create book invalid" do
|
312
|
+
assert_no_difference('Book.count') do
|
313
|
+
xhr :post, :create, book: { name: nil }
|
314
|
+
end
|
315
|
+
|
316
|
+
assert_template 'message_popup'
|
317
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
318
|
+
end
|
319
|
+
|
320
|
+
should "not show book in HTML" do
|
321
|
+
get :show, id: @book
|
322
|
+
assert_redirected_to top_path
|
323
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
324
|
+
end
|
325
|
+
|
326
|
+
should "not show book in JS" do
|
327
|
+
xhr :get, :show, id: @book
|
328
|
+
assert_template 'message_popup'
|
329
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
330
|
+
end
|
331
|
+
|
332
|
+
should "not update book" do
|
333
|
+
assert_no_difference('Book.count') do
|
334
|
+
xhr :put, :update, id: @book, book: { name: @book.name }
|
335
|
+
end
|
336
|
+
assert_template 'message_popup'
|
337
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
338
|
+
assert_not_equal 'X', @book.reload.name
|
339
|
+
end
|
340
|
+
|
341
|
+
should "not destroy book" do
|
342
|
+
assert_no_difference('Book.count') do
|
343
|
+
xhr :delete, :destroy, id: @book
|
344
|
+
end
|
345
|
+
assert_template 'message_popup'
|
346
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
347
|
+
end
|
348
|
+
|
349
|
+
# additional routes tests
|
350
|
+
|
351
|
+
should "not clear" do
|
352
|
+
assert_no_difference('Book.count') do
|
353
|
+
xhr :get, :clear
|
354
|
+
end
|
355
|
+
assert_template 'message_popup'
|
356
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
357
|
+
end
|
358
|
+
|
359
|
+
should "not csv_download" do
|
360
|
+
get :csv_download
|
361
|
+
assert_redirected_to top_path
|
362
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
363
|
+
end
|
364
|
+
|
365
|
+
should 'not search' do
|
366
|
+
xhr :get, :search, edgarj_search_form: {_id: books(:tacit_dimension).id}
|
367
|
+
assert_template 'message_popup'
|
368
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
369
|
+
end
|
370
|
+
|
371
|
+
should 'not search_clear' do
|
372
|
+
xhr :get, :search_clear
|
373
|
+
assert_template 'message_popup'
|
374
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
375
|
+
end
|
376
|
+
|
377
|
+
should 'not search_save' do
|
378
|
+
skip 'search_save'
|
379
|
+
end
|
380
|
+
|
381
|
+
should 'not search_load' do
|
382
|
+
skip 'search_load'
|
383
|
+
end
|
384
|
+
|
385
|
+
=begin
|
386
|
+
should 'not zip_complete' do
|
387
|
+
xhr :get, :zip_complete,
|
388
|
+
zip: '1000000',
|
389
|
+
adrs_prefix: :book_adrs_attributes_
|
390
|
+
assert_nil assigns(:address)
|
391
|
+
assert_template 'message_popup'
|
392
|
+
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
393
|
+
end
|
394
|
+
=end
|
395
|
+
|
396
|
+
# test Edgarj::AuthenticationMixin
|
397
|
+
|
398
|
+
should 'current_user' do
|
399
|
+
get :index
|
400
|
+
assert_equal users(:not_permitted), @controller.send(:current_user)
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
404
|
+
context 'not-login' do
|
405
|
+
setup do
|
406
|
+
@book = books(:tacit_dimension)
|
407
|
+
end
|
408
|
+
|
409
|
+
should "not get index" do
|
410
|
+
get :index
|
411
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
412
|
+
end
|
413
|
+
|
414
|
+
should "not paginate" do
|
415
|
+
xhr :get, :index, page: 2
|
416
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
417
|
+
end
|
418
|
+
|
419
|
+
should "not sort" do
|
420
|
+
xhr :put, :page_info_save,
|
421
|
+
id: edgarj_page_infos(:book_reader_books).id,
|
422
|
+
edgarj_page_info: {
|
423
|
+
dir: 'asc',
|
424
|
+
order_by: 'name'
|
425
|
+
}
|
426
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
427
|
+
end
|
428
|
+
|
429
|
+
should "not create book" do
|
430
|
+
assert_no_difference('Book.count') do
|
431
|
+
xhr :post, :create, book: { name: @book.name }
|
432
|
+
end
|
433
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
434
|
+
end
|
435
|
+
|
436
|
+
should "not create book invalid" do
|
437
|
+
assert_no_difference('Book.count') do
|
438
|
+
xhr :post, :create, book: { name: nil }
|
439
|
+
end
|
440
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
441
|
+
end
|
442
|
+
|
443
|
+
should "not show book in HTML" do
|
444
|
+
get :show, id: @book
|
445
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
446
|
+
end
|
447
|
+
|
448
|
+
should "not show book in JS" do
|
449
|
+
xhr :get, :show, id: @book
|
450
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
451
|
+
end
|
452
|
+
|
453
|
+
should "not update book" do
|
454
|
+
assert_no_difference('Book.count') do
|
455
|
+
xhr :put, :update, id: @book, book: { name: @book.name }
|
456
|
+
end
|
457
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
458
|
+
end
|
459
|
+
|
460
|
+
should "not destroy book" do
|
461
|
+
assert_no_difference('Book.count') do
|
462
|
+
xhr :delete, :destroy, id: @book
|
463
|
+
end
|
464
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
465
|
+
end
|
466
|
+
|
467
|
+
# additional routes tests
|
468
|
+
|
469
|
+
should "not clear" do
|
470
|
+
assert_no_difference('Book.count') do
|
471
|
+
xhr :get, :clear
|
472
|
+
end
|
473
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
474
|
+
end
|
475
|
+
|
476
|
+
should "not csv_download" do
|
477
|
+
get :csv_download
|
478
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
479
|
+
end
|
480
|
+
|
481
|
+
should 'not search' do
|
482
|
+
xhr :get, :search, edgarj_search_form: {_id: books(:tacit_dimension).id}
|
483
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
484
|
+
end
|
485
|
+
|
486
|
+
should 'not search_clear' do
|
487
|
+
xhr :get, :search_clear
|
488
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
489
|
+
end
|
490
|
+
|
491
|
+
should 'not search_save' do
|
492
|
+
skip 'search_save'
|
493
|
+
end
|
494
|
+
|
495
|
+
should 'not search_load' do
|
496
|
+
skip 'search_load'
|
497
|
+
end
|
498
|
+
|
499
|
+
=begin
|
500
|
+
should 'not zip_complete' do
|
501
|
+
xhr :get, :zip_complete,
|
502
|
+
zip: '1000000',
|
503
|
+
adrs_prefix: :book_adrs_attributes_
|
504
|
+
assert_template 'edgarj/sssns/new'
|
505
|
+
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
506
|
+
end
|
507
|
+
=end
|
508
|
+
|
509
|
+
# test Edgarj::AuthenticationMixin
|
510
|
+
|
511
|
+
should 'be nil current_user' do
|
512
|
+
get :index
|
513
|
+
assert_nil @controller.send(:current_user)
|
514
|
+
end
|
515
|
+
end
|
516
|
+
end
|
data/test/edgar_test.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
m_polanyi:
|
2
|
+
name: Michael Polanyi
|
3
|
+
user_group_id: <%= Edgarj::label('author_assignee_science_rep') %>
|
4
|
+
created_at: <%= Time.zone.local(2012, 9,29,23,59,59).to_s(:db) %>
|
5
|
+
|
6
|
+
t_nangou:
|
7
|
+
name: Tsugumasa Nangou
|
8
|
+
user_group_id: <%= Edgarj::label('author_assignee_science_rep') %>
|
9
|
+
created_at: <%= Time.zone.local(2012, 9,30,23,59,59).to_s(:db) %>
|
10
|
+
|
11
|
+
e_masuda:
|
12
|
+
name: Etsusuke Masuda
|
13
|
+
created_at: <%= Time.zone.local(2012,10, 1, 0, 0, 0).to_s(:db) %>
|
14
|
+
|
15
|
+
y_yasuhiko:
|
16
|
+
name: Yoshikazu Yasuhiko
|
17
|
+
user_group_id: <%= Edgarj::label('author_assignee_comic_rep') %>
|
18
|
+
created_at: <%= Time.zone.local(2012,10, 1, 0, 0, 1).to_s(:db) %>
|
19
|
+
|
20
|
+
r_yamagishi:
|
21
|
+
name: Ryoko Yamagishi
|
22
|
+
user_group_id: <%= Edgarj::label('author_assignee_comic_rep') %>
|
23
|
+
created_at: <%= Time.zone.local(2012,10, 1,23,59,59).to_s(:db) %>
|
24
|
+
|
25
|
+
m_hagio:
|
26
|
+
name: Moto Hagio
|
27
|
+
user_group_id: <%= Edgarj::label('author_assignee_comic_rep') %>
|
28
|
+
created_at: <%= Time.zone.local(2012,10, 2, 0, 0, 0).to_s(:db) %>
|
29
|
+
|
30
|
+
homeless:
|
31
|
+
name: Homeless Writer
|
32
|
+
created_at: <%= Time.zone.local(2012,10, 2, 0, 0, 1).to_s(:db) %>
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# for edgarj:scaffold generated controller test
|
2
|
+
one:
|
3
|
+
author: m_polanyi
|
4
|
+
name: The Tacit Dimension
|
5
|
+
|
6
|
+
tacit_dimension:
|
7
|
+
author: m_polanyi
|
8
|
+
name: The Tacit Dimension
|
9
|
+
|
10
|
+
personal_knowledge:
|
11
|
+
author: m_polanyi
|
12
|
+
name: Personal Knowledge
|
13
|
+
|
14
|
+
meaning:
|
15
|
+
author: m_polanyi
|
16
|
+
name: Meaning
|
17
|
+
|
18
|
+
logic_of_liberty:
|
19
|
+
author: m_polanyi
|
20
|
+
name: Logic of Liberty
|
21
|
+
|
22
|
+
knowing_n_being:
|
23
|
+
author: m_polanyi
|
24
|
+
name: Knowing and Being
|
25
|
+
|
26
|
+
science_of_budo:
|
27
|
+
author: t_nangou
|
28
|
+
name: Science of Budo
|
29
|
+
|
30
|
+
what_is_budo:
|
31
|
+
author: t_nangou
|
32
|
+
name: What is Budo
|
33
|
+
|
34
|
+
the_way_of_budo_training:
|
35
|
+
author: t_nangou
|
36
|
+
name: The way of Budo Training
|
37
|
+
|
38
|
+
miracle_of_japan_history:
|
39
|
+
author: e_masuda
|
40
|
+
name: Miracle of Japan History
|
41
|
+
|
42
|
+
the_origin_01:
|
43
|
+
author: y_yasuhiko
|
44
|
+
name: Mobile Suit Gundam THE ORIGIN 01
|
45
|
+
|
46
|
+
the_origin_02:
|
47
|
+
author: y_yasuhiko
|
48
|
+
name: Mobile Suit Gundam THE ORIGIN 02
|
49
|
+
|
50
|
+
the_origin_03:
|
51
|
+
author: y_yasuhiko
|
52
|
+
name: Mobile Suit Gundam THE ORIGIN 03
|
53
|
+
|
54
|
+
the_origin_04:
|
55
|
+
author: y_yasuhiko
|
56
|
+
name: Mobile Suit Gundam THE ORIGIN 04
|