edgarj 0.02.00 → 4.00.01
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.rdoc +8 -2
- data/Rakefile +3 -9
- data/app/views/edgarj/popup/_message_popup.html.erb +1 -0
- data/app/views/edgarj/popup/message_popup.js.erb +1 -0
- data/lib/edgarj.rb +2 -2
- data/lib/edgarj/engine.rb +4 -6
- data/lib/edgarj/version.rb +1 -1
- data/lib/tasks/edgarj_tasks.rake +4 -32
- data/lib/tasks/{pakcage.rake → package.rake} +1 -1
- data/test/{functional → controllers}/edgarj/edgarj_controller_test.rb +0 -0
- data/test/{functional → controllers}/edgarj/model_permissions_controller_test.rb +0 -0
- data/test/{functional → controllers}/edgarj/user_group_users_controller_test.rb +0 -0
- data/test/dummy/app/models/user.rb +0 -2
- data/test/dummy/config.ru +1 -1
- data/test/dummy/config/application.rb +0 -36
- data/test/dummy/config/boot.rb +4 -9
- data/test/dummy/config/database.yml +8 -8
- data/test/dummy/config/environments/development.rb +7 -17
- data/test/dummy/config/environments/production.rb +2 -1
- data/test/dummy/config/environments/test.rb +7 -2
- data/test/dummy/config/initializers/config.rb +3 -0
- data/test/dummy/config/initializers/secret_token.rb +1 -1
- data/test/dummy/config/settings/development.yml +0 -0
- data/test/dummy/config/settings/production.yml +0 -0
- data/test/dummy/config/settings/test.yml +0 -0
- data/test/dummy/db/schema.rb +34 -34
- data/test/dummy/test/{functional → controllers}/authors_controller_test.rb +0 -0
- data/test/dummy/test/{functional → controllers}/authors_popup_controller_test.rb +0 -0
- data/test/dummy/test/{functional → controllers}/books_controller_test.rb +0 -0
- data/test/dummy/test/{unit → models}/author_test.rb +0 -0
- data/test/dummy/test/{unit → models}/book_test.rb +0 -0
- data/test/dummy/test/{unit → models}/rails_config_test.rb +0 -0
- data/test/{edgar_test.rb → edgarj_test.rb} +0 -0
- data/test/fixtures/edgarj/model_permissions.yml +14 -14
- data/test/fixtures/edgarj/page_infos.yml +3 -3
- data/test/{unit → models}/edgarj/model_permission_test.rb +0 -0
- data/test/{unit → models}/edgarj/page_info_test.rb +0 -0
- data/test/{unit → models}/edgarj/sssn_test.rb +1 -1
- data/test/{unit → models}/edgarj/user_group_test.rb +0 -0
- data/test/{unit → models}/edgarj/user_group_user_test.rb +0 -0
- data/test/{unit → models}/helpers/edgarj/model_permissions_helper_test.rb +0 -0
- data/test/{unit → models}/helpers/edgarj/user_group_users_helper_test.rb +0 -0
- data/test/test_helper.rb +3 -3
- metadata +115 -154
- data/app/views/edgarj/popup/_message_popup.html.erb +0 -15
- data/app/views/edgarj/popup/message_popup.js.erb +0 -3
- data/lib/core_ext/rails_config.rb +0 -10
- data/lib/edgarj/templates/rails/helper/helper.rb +0 -10
- data/lib/edgarj/templates/test_unit/scaffold/functional_test.rb +0 -575
- data/lib/generators/edgarj/popup_scaffold/USAGE +0 -6
- data/lib/generators/edgarj/popup_scaffold/popup_scaffold_generator.rb +0 -35
- data/lib/generators/edgarj/popup_scaffold/templates/controller.rb +0 -13
- data/lib/generators/edgarj/popup_scaffold/templates/functional_test.rb +0 -207
- data/lib/generators/edgarj/popup_scaffold/templates/helper.rb +0 -9
- data/lib/generators/edgarj/scaffold/USAGE +0 -17
- data/lib/generators/edgarj/scaffold/scaffold_generator.rb +0 -40
- data/lib/generators/edgarj/scaffold/templates/controller.rb +0 -13
- data/test/dummy/config/initializers/strong_parameter.rb +0 -3
- data/test/dummy/script/rails +0 -6
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
|
3
|
-
module Edgarj
|
4
|
-
class PopupScaffoldGenerator < Rails::Generators::NamedBase
|
5
|
-
include Rails::Generators::ResourceHelpers
|
6
|
-
|
7
|
-
source_root File.expand_path('../templates', __FILE__)
|
8
|
-
|
9
|
-
def add_edgarj_routes
|
10
|
-
route "edgarj_popup_resources :#{file_name.pluralize}_popup"
|
11
|
-
end
|
12
|
-
|
13
|
-
def create_controller_files
|
14
|
-
template 'controller.rb', File.join('app/controllers',
|
15
|
-
class_path, "#{controller_file_name}_popup_controller.rb")
|
16
|
-
end
|
17
|
-
|
18
|
-
=begin
|
19
|
-
hook_for :test_framework, as: :popup_scaffold
|
20
|
-
hook_for :helper, in: :rails, as: :popup_scaffold do |invoked|
|
21
|
-
invoke invoked, [ controller_name ]
|
22
|
-
end
|
23
|
-
=end
|
24
|
-
|
25
|
-
def create_test
|
26
|
-
template 'functional_test.rb', File.join('test/functional',
|
27
|
-
class_path, "#{controller_file_name}_popup_controller_test.rb")
|
28
|
-
end
|
29
|
-
|
30
|
-
def create_helper
|
31
|
-
template 'helper.rb', File.join('app/helpers',
|
32
|
-
class_path, "#{controller_file_name}_popup_helper.rb")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
<% model_name = class_name.singularize -%>
|
2
|
-
<% if namespaced? -%>
|
3
|
-
require_dependency "<%= namespaced_file_path %>/application_controller"
|
4
|
-
|
5
|
-
<% end -%>
|
6
|
-
<% module_namespacing do -%>
|
7
|
-
class <%= controller_class_name %>PopupController < Edgarj::PopupController
|
8
|
-
private
|
9
|
-
def drawer_class
|
10
|
-
<%= controller_class_name %>PopupHelper::<%= model_name -%>PopupDrawer
|
11
|
-
end
|
12
|
-
end
|
13
|
-
<% end -%>
|
@@ -1,207 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
<% module_namespacing do -%>
|
4
|
-
class <%= controller_class_name %>PopupControllerTest < ActionController::TestCase
|
5
|
-
context 'root user' do
|
6
|
-
setup do
|
7
|
-
login_as(:root)
|
8
|
-
@pi = create_page_info(@sssn, '<%= table_name %>', <%= class_name %>)
|
9
|
-
end
|
10
|
-
|
11
|
-
should 'get index' do
|
12
|
-
xhr :get, :index,
|
13
|
-
id_target: "PARENT_MODEL_DOM_ID"
|
14
|
-
assert_response :success
|
15
|
-
assert_not_nil assigns(:list)
|
16
|
-
assert_no_app_error
|
17
|
-
end
|
18
|
-
|
19
|
-
should 'paginate' do
|
20
|
-
xhr :get, :index, page: 2,
|
21
|
-
id_target: "PARENT_MODEL_DOM_ID"
|
22
|
-
assert_response :success
|
23
|
-
assert_not_nil assigns(:list)
|
24
|
-
assert_no_app_error
|
25
|
-
end
|
26
|
-
|
27
|
-
should 'sort' do
|
28
|
-
xhr :put, :page_info_save, id: @pi.id,
|
29
|
-
id_target: "PARENT_MODEL_DOM_ID",
|
30
|
-
edgarj_page_info: {
|
31
|
-
dir: 'asc',
|
32
|
-
order_by: 'created_at'
|
33
|
-
}
|
34
|
-
assert_response :success
|
35
|
-
assert_not_nil assigns(:list)
|
36
|
-
assert_equal 'asc', assigns(:page_info).dir
|
37
|
-
assert_equal 'created_at', assigns(:page_info).order_by
|
38
|
-
assert_no_app_error
|
39
|
-
end
|
40
|
-
|
41
|
-
should 'search' do
|
42
|
-
xhr :get, :search, edgarj_search_form: {},
|
43
|
-
id_target: "PARENT_MODEL_DOM_ID"
|
44
|
-
assert_response :success
|
45
|
-
assert assigns(:list).count >= 1
|
46
|
-
assert_no_app_error
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
# All of tests in this context is skipped because it is required
|
51
|
-
# to prepare read-only user.
|
52
|
-
# When complete the preparation, delete the skip lines.
|
53
|
-
context 'read-only user' do
|
54
|
-
setup do
|
55
|
-
# prepare fixtures of model_permissions, user_groups, and
|
56
|
-
# user_group_users for read-only user of the
|
57
|
-
# <%= controller_class_name %>Controller and login by him/her.
|
58
|
-
#
|
59
|
-
login_as(:<%= singular_table_name %>_reader)
|
60
|
-
@pi = create_page_info(@sssn, '<%= table_name %>', <%= class_name %>)
|
61
|
-
end
|
62
|
-
|
63
|
-
should 'get index' do
|
64
|
-
skip 'get index'
|
65
|
-
xhr :get, :index,
|
66
|
-
id_target: "PARENT_MODEL_DOM_ID"
|
67
|
-
assert_response :success
|
68
|
-
assert_not_nil assigns(:list)
|
69
|
-
assert_no_app_error
|
70
|
-
end
|
71
|
-
|
72
|
-
should 'paginate' do
|
73
|
-
skip 'get paginate'
|
74
|
-
xhr :get, :index, page: 2,
|
75
|
-
id_target: "PARENT_MODEL_DOM_ID"
|
76
|
-
assert_response :success
|
77
|
-
assert_not_nil assigns(:list)
|
78
|
-
assert_no_app_error
|
79
|
-
end
|
80
|
-
|
81
|
-
should 'sort' do
|
82
|
-
skip 'sort'
|
83
|
-
xhr :put, :page_info_save, id: @pi.id,
|
84
|
-
id_target: "PARENT_MODEL_DOM_ID",
|
85
|
-
edgarj_page_info: {
|
86
|
-
dir: 'asc',
|
87
|
-
order_by: 'created_at'
|
88
|
-
}
|
89
|
-
assert_response :success
|
90
|
-
assert_not_nil assigns(:list)
|
91
|
-
assert_equal 'asc', assigns(:page_info).dir
|
92
|
-
assert_equal 'created_at', assigns(:page_info).order_by
|
93
|
-
assert_no_app_error
|
94
|
-
end
|
95
|
-
|
96
|
-
should 'search' do
|
97
|
-
skip 'search'
|
98
|
-
xhr :get, :search, edgarj_search_form: {},
|
99
|
-
id_target: "PARENT_MODEL_DOM_ID"
|
100
|
-
assert_response :success
|
101
|
-
assert assigns(:list).count >= 1
|
102
|
-
assert_no_app_error
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
# All of tests in this context is skipped because it is required
|
107
|
-
# to prepare 'permitted but user_scoped' user.
|
108
|
-
# When complete the preparation, delete the skip lines.
|
109
|
-
context 'permitted and user_scoped user' do
|
110
|
-
setup do
|
111
|
-
# prepare fixtures of model_permissions, user_groups, and
|
112
|
-
# user_group_users for read-only user of the
|
113
|
-
#login_as(:permitted_n_user_scoped_on_<%= table_name %>)
|
114
|
-
#@pi = create_page_info(@sssn, '<%= table_name %>', <%= class_name %>)
|
115
|
-
@<%= singular_table_name %> = <%= table_name %>(:one)
|
116
|
-
@<%= singular_table_name %>_scoped_out = <%= table_name %>(:two)
|
117
|
-
end
|
118
|
-
|
119
|
-
should 'search since role and user_scoped satisfy' do
|
120
|
-
skip 'search since role and user_scoped satisfy'
|
121
|
-
xhr :get, :search, edgarj_search_form: {col: 'id', val: @<%= singular_table_name %>.id},
|
122
|
-
id_target: "PARENT_MODEL_DOM_ID"
|
123
|
-
assert_response :success
|
124
|
-
assert_equal 1, assigns(:list).count
|
125
|
-
assert_no_app_error
|
126
|
-
end
|
127
|
-
|
128
|
-
should 'not search since key is out-of-scope' do
|
129
|
-
skip 'not search since key is out-of-scope'
|
130
|
-
xhr :get, :search, edgarj_search_form: {col: 'id', val: @<%= singular_table_name %>_scoped_out.id},
|
131
|
-
id_target: "PARENT_MODEL_DOM_ID"
|
132
|
-
assert_response :success
|
133
|
-
assert_equal 0, assigns(:list).count
|
134
|
-
assert_no_app_error
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
context 'not-permitted user' do
|
139
|
-
setup do
|
140
|
-
login_as(:not_permitted)
|
141
|
-
@pi = create_page_info(@sssn, '<%= table_name %>', <%= class_name %>)
|
142
|
-
end
|
143
|
-
|
144
|
-
should 'not get index' do
|
145
|
-
xhr :get, :index,
|
146
|
-
id_target: "PARENT_MODEL_DOM_ID"
|
147
|
-
assert_template 'message_popup'
|
148
|
-
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
149
|
-
end
|
150
|
-
|
151
|
-
should 'not paginate' do
|
152
|
-
xhr :get, :index, page: 2,
|
153
|
-
id_target: "PARENT_MODEL_DOM_ID"
|
154
|
-
assert_template 'message_popup'
|
155
|
-
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
156
|
-
end
|
157
|
-
|
158
|
-
should 'not sort' do
|
159
|
-
xhr :put, :page_info_save, id: @pi.id,
|
160
|
-
id_target: "PARENT_MODEL_DOM_ID",
|
161
|
-
edgarj_page_info: {
|
162
|
-
dir: 'asc',
|
163
|
-
order_by: 'created_at'
|
164
|
-
}
|
165
|
-
assert_template 'message_popup'
|
166
|
-
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
167
|
-
end
|
168
|
-
|
169
|
-
should 'not search' do
|
170
|
-
xhr :get, :search, edgarj_search_form: {},
|
171
|
-
id_target: "PARENT_MODEL_DOM_ID"
|
172
|
-
assert_template 'message_popup'
|
173
|
-
assert_equal I18n.t('edgarj.default.permission_no'), flash[:error]
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
context 'not-login' do
|
178
|
-
should 'not get index' do
|
179
|
-
xhr :get, :index,
|
180
|
-
id_target: "PARENT_MODEL_DOM_ID"
|
181
|
-
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
182
|
-
end
|
183
|
-
|
184
|
-
should 'not paginate' do
|
185
|
-
xhr :get, :index, page: 2,
|
186
|
-
id_target: "PARENT_MODEL_DOM_ID"
|
187
|
-
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
188
|
-
end
|
189
|
-
|
190
|
-
should 'not sort' do
|
191
|
-
xhr :put, :page_info_save, id: 0,
|
192
|
-
id_target: "PARENT_MODEL_DOM_ID",
|
193
|
-
edgarj_page_info: {
|
194
|
-
dir: 'asc',
|
195
|
-
order_by: 'created_at'
|
196
|
-
}
|
197
|
-
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
198
|
-
end
|
199
|
-
|
200
|
-
should 'not search' do
|
201
|
-
xhr :get, :search, edgarj_search_form: {},
|
202
|
-
id_target: "PARENT_MODEL_DOM_ID"
|
203
|
-
assert_equal I18n.t('edgarj.default.login_failed'), flash[:error]
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
207
|
-
<% end -%>
|
@@ -1,17 +0,0 @@
|
|
1
|
-
Description:
|
2
|
-
'edgarj:scaffold' is similar to original scaffold, but adds the followings:
|
3
|
-
|
4
|
-
* CRUD with Ajax
|
5
|
-
* QBE search form
|
6
|
-
* sort by clicking list column header
|
7
|
-
* csv-download
|
8
|
-
* role-based access control on controller
|
9
|
-
* data-scope access control on data model
|
10
|
-
|
11
|
-
If you want to remove all the generated files, run
|
12
|
-
'rails destroy edgarj/scaffold ModelName'.
|
13
|
-
|
14
|
-
Example:
|
15
|
-
`rails generate edgarj:scaffold Author name`
|
16
|
-
`rails generate edgarj:scaffold Book name desc:text author:belongs_to`
|
17
|
-
`rails generate edgarj:scaffold Purchase amount:decimal tracking_id:integer:uniq`
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
|
3
|
-
module Edgarj
|
4
|
-
class ScaffoldGenerator < Rails::Generators::NamedBase
|
5
|
-
include Rails::Generators::ResourceHelpers
|
6
|
-
|
7
|
-
source_root File.expand_path('../templates', __FILE__)
|
8
|
-
invoke :model, in: :rails
|
9
|
-
|
10
|
-
def add_edgarj_routes
|
11
|
-
route "edgarj_resources :#{file_name.pluralize}"
|
12
|
-
end
|
13
|
-
|
14
|
-
def create_controller_files
|
15
|
-
template 'controller.rb', File.join('app/controllers',
|
16
|
-
class_path, "#{controller_file_name}_controller.rb")
|
17
|
-
end
|
18
|
-
|
19
|
-
hook_for :test_framework, as: :scaffold
|
20
|
-
hook_for :helper, in: :rails, as: :scaffold do |invoked|
|
21
|
-
invoke invoked, [ controller_name ]
|
22
|
-
end
|
23
|
-
|
24
|
-
=begin
|
25
|
-
private
|
26
|
-
# copied from TestUnit::Generators::ScaffoldGenerator
|
27
|
-
def attributes_hash
|
28
|
-
return if attributes_names.empty?
|
29
|
-
|
30
|
-
attributes_names.map do |name|
|
31
|
-
if %w(password password_confirmation).include?(name) && attributes.any?(&:password_digest?)
|
32
|
-
"#{name}: 'secret'"
|
33
|
-
else
|
34
|
-
"#{name}: @#{singular_table_name}.#{name}"
|
35
|
-
end
|
36
|
-
end.sort.join(', ')
|
37
|
-
end
|
38
|
-
=end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
<% model_name = class_name.singularize -%>
|
2
|
-
<% if namespaced? -%>
|
3
|
-
require_dependency "<%= namespaced_file_path %>/application_controller"
|
4
|
-
|
5
|
-
<% end -%>
|
6
|
-
<% module_namespacing do -%>
|
7
|
-
class <%= controller_class_name %>Controller < Edgarj::EdgarjController
|
8
|
-
private
|
9
|
-
def drawer_class
|
10
|
-
<%= controller_class_name %>Helper::<%= model_name -%>Drawer
|
11
|
-
end
|
12
|
-
end
|
13
|
-
<% end -%>
|
data/test/dummy/script/rails
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
-
|
4
|
-
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
-
require File.expand_path('../../config/boot', __FILE__)
|
6
|
-
require 'rails/commands'
|