active_leonardo 0.0.5 → 0.0.6.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/active_template.rb +22 -3
- data/lib/generators/active_leonardo.rb +99 -68
- data/lib/generators/leolay/leolay_generator.rb +48 -48
- data/lib/generators/leolay/templates/app/admin/users.rb +4 -0
- data/lib/generators/leolay/templates/config/config.yml +21 -0
- data/lib/generators/leolay/templates/config/initializers/config.rb +2 -0
- data/lib/generators/leolay/templates/spec/factories.rb +23 -0
- data/lib/generators/leolay/templates/spec/helpers/application_helpers_spec.rb +13 -0
- data/lib/generators/leolay/templates/spec/support/devise.rb +4 -0
- data/lib/generators/rails/leosca_controller/leosca_controller_generator.rb +19 -18
- data/lib/generators/rspec/leointegration/leointegration_generator.rb +32 -0
- data/lib/generators/rspec/leointegration/templates/request_spec.rb +70 -0
- data/lib/generators/rspec/leosca/leosca_generator.rb +49 -0
- data/lib/generators/rspec/leosca/templates/controller_spec.rb +181 -0
- data/lib/generators/rspec/leosca/templates/edit_spec.rb +31 -0
- data/lib/generators/rspec/leosca/templates/index_spec.rb +32 -0
- data/lib/generators/rspec/leosca/templates/new_spec.rb +30 -0
- data/lib/generators/rspec/leosca/templates/routing_spec.rb +39 -0
- data/lib/generators/rspec/leosca/templates/show_spec.rb +28 -0
- metadata +41 -16
- data/lib/generators/leolay/templates/config.rb +0 -11
data/CHANGELOG
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
0.0.6 (September 26th, 2012) Marco Mastrodonato
|
2
|
+
* Configuration parameters moved into a yaml file (config.yml)
|
3
|
+
* Template updated
|
4
|
+
|
1
5
|
0.0.5 (September 26th, 2012) Marco Mastrodonato
|
2
6
|
* Added support to activeadmin 0.0.5
|
3
7
|
* Added cancan's unauthorized message to localization
|
data/active_template.rb
CHANGED
@@ -39,10 +39,23 @@ if use_git
|
|
39
39
|
end
|
40
40
|
|
41
41
|
gem "activeadmin"
|
42
|
+
gem "active_admin_editor"
|
42
43
|
gem "meta_search"
|
43
44
|
gem "active_leonardo"
|
44
45
|
|
45
|
-
|
46
|
+
rspec = yes?("Add rspec as testing framework ?")
|
47
|
+
if rspec
|
48
|
+
gem 'rspec-rails', :group => [:test, :development]
|
49
|
+
gem 'capybara', :group => :test
|
50
|
+
gem 'launchy', :group => :test
|
51
|
+
gem 'database_cleaner', :group => :test
|
52
|
+
if /1.8.*/ === RUBY_VERSION
|
53
|
+
gem 'factory_girl', '2.6.4', :group => :test
|
54
|
+
gem 'factory_girl_rails', '1.7.0', :group => :test
|
55
|
+
else
|
56
|
+
gem 'factory_girl_rails', :group => :test
|
57
|
+
end
|
58
|
+
end
|
46
59
|
|
47
60
|
authentication = yes?("Authentication ?")
|
48
61
|
model_name = authorization = nil
|
@@ -70,6 +83,8 @@ if authentication
|
|
70
83
|
end
|
71
84
|
end
|
72
85
|
|
86
|
+
gem 'state_machine' if yes?("Do you have to handle states ?")
|
87
|
+
|
73
88
|
dashboard_root = yes?("Would you use dashboard as root ? (recommended)")
|
74
89
|
home = yes?("Ok. Would you create home controller as root ?") unless dashboard_root
|
75
90
|
|
@@ -78,7 +93,10 @@ if yes?("Bundle install ?")
|
|
78
93
|
run "bundle install #{"--path=#{dir}" unless dir.empty? || dir=='y'}"
|
79
94
|
end
|
80
95
|
|
96
|
+
generate "rspec:install" if rspec
|
97
|
+
|
81
98
|
generate "active_admin:install #{authentication ? model_name : "--skip-users"}"
|
99
|
+
generate "active_admin:editor"
|
82
100
|
|
83
101
|
if authorization
|
84
102
|
generate "cancan:ability"
|
@@ -88,8 +106,9 @@ end
|
|
88
106
|
generate "leolay",
|
89
107
|
"active", #specify theme
|
90
108
|
"--auth_class=#{model_name}",
|
91
|
-
(
|
92
|
-
(
|
109
|
+
(rspec ? nil : "--skip-rspec"),
|
110
|
+
(authorization ? nil : "--skip-authorization"),
|
111
|
+
(authentication ? nil : "--skip-authentication")
|
93
112
|
|
94
113
|
|
95
114
|
if dashboard_root
|
@@ -57,41 +57,41 @@ module ActiveLeonardo
|
|
57
57
|
end
|
58
58
|
" #{name} => #{value}"
|
59
59
|
end
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
60
|
+
def attribute_to_factories(attribute)
|
61
|
+
spaces = 34
|
62
|
+
space_association = " " * (spaces-11).abs
|
63
|
+
space_sequence = " " * (spaces-attribute.name.size-11).abs
|
64
|
+
space_other = " " * (spaces-attribute.name.size).abs
|
65
|
+
name = case attribute.type
|
66
|
+
when :references, :belongs_to then "#{singular_table_name[0..0]}.association#{space_association}"
|
67
|
+
when :boolean, :datetime, :time, :timestamp
|
68
|
+
then "#{singular_table_name[0..0]}.#{attribute.name}#{space_other}"
|
69
|
+
else "#{singular_table_name[0..0]}.sequence(:#{attribute.name})#{space_sequence}"
|
70
|
+
end
|
71
|
+
value = case attribute.type
|
72
|
+
when :boolean then "true"
|
73
|
+
when :integer then "{|n| n }"
|
74
|
+
when :float, :decimal then "{|n| n }"
|
75
|
+
when :references, :belongs_to then ":#{attribute.name}"
|
76
|
+
when :date then "{|n| n.month.ago }"
|
77
|
+
when :datetime then "#{Time.now.strftime("%Y-%m-%d %H:%M:%S.000")}".inspect
|
78
|
+
when :time, :timestamp then "#{Time.now.strftime("%H:%M:%S.000")}".inspect
|
79
|
+
else "{|n| \"#{attribute.name.titleize}\#{n}\" }"
|
80
|
+
end
|
81
|
+
" #{name}#{value}"
|
82
|
+
end
|
83
|
+
def attribute_to_requests(attribute, object_id=nil)
|
84
|
+
object_id ||= "#{singular_table_name}_#{attribute.name}"
|
85
|
+
object_id = object_id.gsub('#', "\#{#{singular_table_name}.id}").gsub('name', attribute.name)
|
86
|
+
case attribute.type
|
87
|
+
when :boolean then "check \"#{object_id}\" if #{singular_table_name}.#{attribute.name}"
|
88
|
+
when :references, :belongs_to then "select #{singular_table_name}.#{attribute.name}.name, :from => \"#{object_id}_id\""
|
89
|
+
when :datetime, :time, :timestamp
|
90
|
+
then ""
|
91
|
+
when :date then "fill_in \"#{object_id}\", :with => #{singular_table_name}.#{attribute.name}.strftime('%d-%m-%Y')"
|
92
|
+
else "fill_in \"#{object_id}\", :with => #{singular_table_name}.#{attribute.name}"
|
93
|
+
end
|
94
|
+
end
|
95
95
|
#def attribute_to_erb(attribute, object)
|
96
96
|
# case attribute.name
|
97
97
|
# when "state" then "<span class=\"state generic <%= #{object}.state_name.to_s %>\"><%= t(\"states.generic.\#{#{object}.state_name.to_s}\") %></span><span style=\"display:block;\"></span>"
|
@@ -109,39 +109,39 @@ module ActiveLeonardo
|
|
109
109
|
# end
|
110
110
|
# end
|
111
111
|
#end
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
112
|
+
def get_attr_to_match(view=:list)
|
113
|
+
#attributes.each do |attribute|
|
114
|
+
# case attribute.type
|
115
|
+
# when :string, :text then
|
116
|
+
# return "have_content(#{singular_table_name}.#{attribute.name})",
|
117
|
+
# "have_no_content(#{singular_table_name}.#{attribute.name})"
|
118
|
+
# end
|
119
|
+
#end
|
120
|
+
attr = get_attr_to_check(view)
|
121
|
+
return "have_content(#{singular_table_name}.#{attr})",
|
122
|
+
"have_no_content(#{singular_table_name}.#{attr})" if attr
|
123
|
+
|
124
|
+
#If there are not string or text attributes
|
125
|
+
case view
|
126
|
+
when :list
|
127
|
+
return "have_xpath('//table/tbody/tr')", "have_no_xpath('//table/tbody/tr')"
|
128
|
+
when :show
|
129
|
+
return "have_xpath('//table/tbody/tr')", "have_no_xpath('//table/tbody/tr')"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
def get_attr_to_check(view=:list)
|
133
|
+
case view
|
134
|
+
when :something
|
135
|
+
else
|
136
|
+
attributes.each{|a| case a.type when :string, :text then return a.name end}
|
137
|
+
attributes.each{|a| case a.type when :references, :belongs_to, :datetime then nil else return a.name end}
|
138
|
+
end
|
139
|
+
end
|
140
|
+
def fill_form_with_values(object_id=nil)
|
141
|
+
items = []
|
142
|
+
attributes.each{|a|items << " #{attribute_to_requests(a, object_id)}"}
|
143
|
+
items
|
144
|
+
end
|
145
145
|
end
|
146
146
|
|
147
147
|
#module Nested
|
@@ -344,4 +344,35 @@ module ActiveLeonardo
|
|
344
344
|
# end
|
345
345
|
# end
|
346
346
|
#end
|
347
|
+
module Test
|
348
|
+
protected
|
349
|
+
def get_activespace
|
350
|
+
activespace ||= options[:activespace]
|
351
|
+
"#{activespace}_" if activespace
|
352
|
+
end
|
353
|
+
|
354
|
+
#product => activespace_products_path
|
355
|
+
def list_resources_path_test(resource=nil)
|
356
|
+
resource ||= plural_table_name
|
357
|
+
"#{get_activespace}#{resource}_path"
|
358
|
+
end
|
359
|
+
|
360
|
+
#product => "[:activespace, product]"
|
361
|
+
def show_resource_path_test(resource=nil)
|
362
|
+
resource ||= singular_table_name
|
363
|
+
"[:#{get_activespace}, #{resource}]"
|
364
|
+
end
|
365
|
+
|
366
|
+
#product => new_activespace_product_path
|
367
|
+
def new_resource_path_test(resource=nil)
|
368
|
+
resource ||= singular_table_name
|
369
|
+
"new_#{get_activespace}#{resource}_path"
|
370
|
+
end
|
371
|
+
|
372
|
+
#product => edit_activespace_product_path
|
373
|
+
def edit_resource_path_test(resource=nil)
|
374
|
+
resource ||= singular_table_name
|
375
|
+
"edit_#{get_activespace}#{resource}_path(#{resource})"
|
376
|
+
end
|
377
|
+
end
|
347
378
|
end
|
@@ -14,8 +14,7 @@ class LeolayGenerator < Rails::Generators::Base
|
|
14
14
|
class_option :auth_class, :type => :string, :default => 'User', :desc => "Set the authentication class name"
|
15
15
|
#class_option :formtastic, :type => :boolean, :default => true, :desc => "Copy formtastic files into leosca custom folder (inside project)"
|
16
16
|
#class_option :jquery_ui, :type => :boolean, :default => true, :desc => "To use jQuery ui improvement"
|
17
|
-
|
18
|
-
#class_option :activeadmin, :type => :boolean, :default => true, :desc => "Include active admin management"
|
17
|
+
class_option :rspec, :type => :boolean, :default => true, :desc => "Include custom rspec generator and custom templates"
|
19
18
|
#class_option :old_views, :type => :boolean, :default => false, :desc => "Include old management"
|
20
19
|
|
21
20
|
#def generate_layout
|
@@ -83,7 +82,8 @@ class LeolayGenerator < Rails::Generators::Base
|
|
83
82
|
copy_file "styles/#{style_name}/views/layout/_message.html.erb", "app/views/application/_message.html.erb"
|
84
83
|
copy_file "styles/#{style_name}/views/layout/_session.html.erb", "app/views/application/_session.html.erb" if options.authentication?
|
85
84
|
|
86
|
-
|
85
|
+
copy_file "config/initializers/config.rb", "config/initializers/config.rb"
|
86
|
+
template "config/config.yml", "config/config.yml"
|
87
87
|
locale_path = "config/locales"
|
88
88
|
source_paths.each do |source_path|
|
89
89
|
files = Dir["#{source_path}/#{locale_path}/??.yml"]
|
@@ -99,7 +99,7 @@ class LeolayGenerator < Rails::Generators::Base
|
|
99
99
|
<<-FILE.gsub(/^ /, '')
|
100
100
|
config.generators do |g|
|
101
101
|
g.stylesheets false
|
102
|
-
g.javascripts
|
102
|
+
g.javascripts true
|
103
103
|
g.leosca_controller :leosca_controller
|
104
104
|
end
|
105
105
|
|
@@ -299,50 +299,50 @@ class LeolayGenerator < Rails::Generators::Base
|
|
299
299
|
# end if options.formtastic?
|
300
300
|
#end
|
301
301
|
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
302
|
+
def setup_rspec
|
303
|
+
file = "spec/spec_helper.rb"
|
304
|
+
return unless File.exists?(file) && options.rspec?
|
305
|
+
inject_into_file file, :after => "require 'rspec/rails'" do
|
306
|
+
<<-FILE.gsub(/^ /, '')
|
307
|
+
|
308
|
+
require 'capybara/rspec'
|
309
|
+
require 'helpers/application_helpers_spec'
|
310
|
+
|
311
|
+
Capybara.default_wait_time = 10 #default=2
|
312
|
+
FILE
|
313
|
+
end
|
314
|
+
|
315
|
+
gsub_file file, 'config.fixture_path = "#{::Rails.root}/spec/fixtures"', '#config.fixture_path = "#{::Rails.root}/spec/fixtures"'
|
316
|
+
#inject_into_file file, "#", :before => 'config.fixture_path = "#{::Rails.root}/spec/fixtures"'
|
317
|
+
|
318
|
+
gsub_file file, "config.use_transactional_fixtures = true" do
|
319
|
+
<<-FILE.gsub(/^ /, '')
|
320
|
+
config.use_transactional_fixtures = false
|
321
|
+
|
322
|
+
config.before(:suite) do
|
323
|
+
DatabaseCleaner.strategy = :truncation
|
324
|
+
end
|
325
|
+
|
326
|
+
config.before(:each) do
|
327
|
+
DatabaseCleaner.start
|
328
|
+
end
|
329
|
+
|
330
|
+
config.after(:each) do
|
331
|
+
DatabaseCleaner.clean
|
332
|
+
end
|
333
|
+
|
334
|
+
config.include ApplicationHelpers
|
335
|
+
FILE
|
336
|
+
end
|
337
|
+
|
338
|
+
file = "spec/factories.rb"
|
339
|
+
copy_file file, file
|
340
|
+
file = "spec/support/devise.rb"
|
341
|
+
copy_file file, file
|
342
|
+
file = "spec/helpers/application_helpers_spec.rb"
|
343
|
+
copy_file file, file
|
344
|
+
|
345
|
+
end
|
346
346
|
|
347
347
|
def setup_extras
|
348
348
|
copy_file "lib/upd_array.rb", "lib/extras/upd_array.rb"
|
@@ -21,6 +21,7 @@ ActiveAdmin.register <%= options[:auth_class] %> do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
index do
|
24
|
+
selectable_column
|
24
25
|
id_column
|
25
26
|
column :email
|
26
27
|
#column :group, :sortable => :group_id
|
@@ -35,6 +36,9 @@ ActiveAdmin.register <%= options[:auth_class] %> do
|
|
35
36
|
default_actions
|
36
37
|
end
|
37
38
|
|
39
|
+
filter :email
|
40
|
+
filter :created_at
|
41
|
+
|
38
42
|
form do |f|
|
39
43
|
<%- if options.authorization? -%>
|
40
44
|
input_roles = "<li>" <<
|
@@ -0,0 +1,21 @@
|
|
1
|
+
defaults: &defaults
|
2
|
+
application:
|
3
|
+
name: "<%= app_name %>"
|
4
|
+
version: "0.0.1"
|
5
|
+
started_at: "<%= Time.now.strftime('%d/%m/%Y') %>"
|
6
|
+
updated_at: "<%= Time.now.strftime('%d/%m/%Y') %>"
|
7
|
+
default_style: "<%= style_name %>"
|
8
|
+
ldap:
|
9
|
+
host: "127.0.0.1"
|
10
|
+
port: 000
|
11
|
+
domain: "your domain"
|
12
|
+
default_pwd: "your password"
|
13
|
+
|
14
|
+
development:
|
15
|
+
<<: *defaults
|
16
|
+
|
17
|
+
test:
|
18
|
+
<<: *defaults
|
19
|
+
|
20
|
+
production:
|
21
|
+
<<: *defaults
|
@@ -0,0 +1,23 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :user do
|
3
|
+
sequence(:email) {|n| "test#{n}@leonardo.com" }
|
4
|
+
password 'abcd1234'
|
5
|
+
roles ['user']
|
6
|
+
|
7
|
+
trait :guest do
|
8
|
+
roles ['guest']
|
9
|
+
end
|
10
|
+
trait :manager do
|
11
|
+
roles ['manager']
|
12
|
+
end
|
13
|
+
trait :admin do
|
14
|
+
roles ['admin']
|
15
|
+
end
|
16
|
+
|
17
|
+
factory :user_guest, :traits => [:guest]
|
18
|
+
factory :user_manager, :traits => [:manager]
|
19
|
+
factory :user_admin, :traits => [:admin]
|
20
|
+
end
|
21
|
+
### ActiveLeonardo creates here below your factories ###
|
22
|
+
### Insert below here other your factories ###
|
23
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ApplicationHelpers
|
2
|
+
def login_view_as(role=:user)
|
3
|
+
user = Factory(role)
|
4
|
+
fill_in 'user_email', :with => user.email
|
5
|
+
fill_in 'user_password', :with => user.password
|
6
|
+
click_button 'Sign in'
|
7
|
+
end
|
8
|
+
def login_controller_as(role=:user)
|
9
|
+
user = Factory(role)
|
10
|
+
#user.confirm! # or set a confirmed_at inside the factory. Only necessary if you are using the confirmable module
|
11
|
+
sign_in user
|
12
|
+
end
|
13
|
+
end
|
@@ -30,6 +30,7 @@ module Rails
|
|
30
30
|
|
31
31
|
#Override
|
32
32
|
#hook_for :template_engine, :test_framework, :as => :leosca
|
33
|
+
hook_for :test_framework, :as => :leosca
|
33
34
|
|
34
35
|
def update_yaml_locales
|
35
36
|
#Inject model and attributes name into yaml files for i18n
|
@@ -149,24 +150,24 @@ module Rails
|
|
149
150
|
end if authorization? && File.exists?(file)
|
150
151
|
end
|
151
152
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
153
|
+
def update_specs
|
154
|
+
file = "spec/spec_helper.rb"
|
155
|
+
return unless File.exists? file
|
156
|
+
|
157
|
+
file = "spec/factories.rb"
|
158
|
+
inject_into_file file, :before => " ### Insert below here other your factories ###" do
|
159
|
+
items = []
|
160
|
+
attributes.each do |attribute|
|
161
|
+
items << attribute_to_factories(attribute)
|
162
|
+
end
|
163
|
+
<<-FILE.gsub(/^ /, '')
|
164
|
+
|
165
|
+
factory :#{singular_table_name} do |#{singular_table_name[0..0]}|
|
166
|
+
#{items.join(CRLF)}
|
167
|
+
end
|
168
|
+
FILE
|
169
|
+
end if File.exists?(file)
|
170
|
+
end
|
170
171
|
|
171
172
|
#def update_parent_controller
|
172
173
|
# return unless nested?
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'generators/rspec/integration/integration_generator'
|
2
|
+
require File.join(File.dirname(__FILE__), '../../active_leonardo')
|
3
|
+
|
4
|
+
module Rspec
|
5
|
+
module Generators
|
6
|
+
class LeointegrationGenerator < ::Rspec::Generators::IntegrationGenerator
|
7
|
+
include ::ActiveLeonardo::Base
|
8
|
+
include ::ActiveLeonardo::Leosca
|
9
|
+
include ::ActiveLeonardo::Test
|
10
|
+
#include ::ActiveLeonardo::Nested
|
11
|
+
#include ::ActiveLeonardo::Nested::Test
|
12
|
+
|
13
|
+
#puts 'Rspec:Generators:LeointegrationGenerator'
|
14
|
+
source_paths << File.expand_path('../templates', __FILE__)
|
15
|
+
|
16
|
+
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
17
|
+
|
18
|
+
class_option :remote, :type => :boolean, :default => true, :desc => "It checks ajax sections"
|
19
|
+
class_option :under, :type => :string, :default => "", :banner => "brand/category", :desc => "Nested resources"
|
20
|
+
class_option :activespace, :type => :string, :default => "admin", :banner => ":admin", :desc => "To nest a resource under namespace(s)"
|
21
|
+
|
22
|
+
def generate_request_spec
|
23
|
+
return unless options[:request_specs]
|
24
|
+
|
25
|
+
template 'request_spec.rb',
|
26
|
+
#File.join('spec/requests', class_path, base_namespaces, "#{table_name}_spec.rb")
|
27
|
+
File.join('spec/requests', class_path, "#{table_name}_spec.rb")
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
<%- check_attr_to_have, check_attr_to_not_have = get_attr_to_match -%>
|
3
|
+
|
4
|
+
describe "<%= class_name.pluralize %>" do
|
5
|
+
describe "GET /<%= table_name %>" do
|
6
|
+
it "displays <%= plural_table_name %>" do
|
7
|
+
<%= singular_table_name %> = Factory(:<%= singular_table_name %>)
|
8
|
+
visit <%= list_resources_path_test %>
|
9
|
+
<%= "login_view_as(:user_guest)" if authentication? -%>
|
10
|
+
#save_and_open_page #uncomment to debug
|
11
|
+
page.should <%= check_attr_to_have %>
|
12
|
+
assert page.find("#tr#{<%= singular_table_name %>.id}").visible?
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "POST /<%= plural_table_name %>" do
|
16
|
+
it "creates a new <%= singular_table_name %>" do
|
17
|
+
<%= singular_table_name %> = Factory.build(:<%= singular_table_name %>)
|
18
|
+
visit <%= new_resource_path_test %>
|
19
|
+
<%= "login_view_as(:user_admin)" if authentication? %>
|
20
|
+
<%= fill_form_with_values.join(CRLF) %>
|
21
|
+
click_button "Create #{I18n.t('models.<%= singular_table_name %>')}"
|
22
|
+
#save_and_open_page #uncomment to debug
|
23
|
+
page.should have_content(I18n.t(:created, :model => I18n.t('models.<%= singular_table_name %>')))
|
24
|
+
page.should <%= check_attr_to_have %>
|
25
|
+
end
|
26
|
+
|
27
|
+
it "edit a <%= singular_table_name %>" do
|
28
|
+
<%= singular_table_name %> = Factory(:<%= singular_table_name %>)
|
29
|
+
visit <%= list_resources_path_test %>
|
30
|
+
<%= "login_view_as(:user_manager)" if authentication? -%>
|
31
|
+
#save_and_open_page #uncomment to debug
|
32
|
+
page.should <%= check_attr_to_have %>
|
33
|
+
assert page.find("#tr#{<%= singular_table_name %>.id}").visible?
|
34
|
+
check("check#{<%= singular_table_name %>.id}")
|
35
|
+
click_link I18n.t(:edit)
|
36
|
+
page.should have_content(I18n.t(:edit))
|
37
|
+
<%= fill_form_with_values("#{plural_table_name}_#_name").join(CRLF) %>
|
38
|
+
click_button I18n.t(:submit)
|
39
|
+
page.should have_content(I18n.t(:show))
|
40
|
+
end
|
41
|
+
|
42
|
+
it "destroy one <%= singular_table_name %>" do
|
43
|
+
<%= singular_table_name %> = Factory(:<%= singular_table_name %>)
|
44
|
+
visit <%= list_resources_path_test %>
|
45
|
+
<%= "login_view_as(:user_manager)" if authentication? -%>
|
46
|
+
#save_and_open_page #uncomment to debug
|
47
|
+
page.should <%= check_attr_to_have %>
|
48
|
+
assert page.find("tr#<%= singular_table_name %>#{<%= singular_table_name %>.id}").visible?
|
49
|
+
click_link I18n.t(:delete)
|
50
|
+
#page.should have_no_content("<%= singular_table_name %>#{<%= singular_table_name %>.id}")
|
51
|
+
assert_not page.find("tr#<%= singular_table_name %>#{<%= singular_table_name %>.id}")
|
52
|
+
end
|
53
|
+
|
54
|
+
it "destroy several <%= plural_table_name %>", :js => true do
|
55
|
+
<%= plural_table_name %> = FactoryGirl.create_list(:<%= singular_table_name %>, 2)
|
56
|
+
visit <%= list_resources_path_test %>
|
57
|
+
<%= "login_view_as(:user_manager)" if authentication? -%>
|
58
|
+
#save_and_open_page #uncomment to debug
|
59
|
+
<%= plural_table_name %>.each do |<%= singular_table_name %>|
|
60
|
+
page.should <%= check_attr_to_have %>
|
61
|
+
assert page.find("tr#<%= singular_table_name %>#{<%= singular_table_name %>.id}").visible?
|
62
|
+
check "batch_action_item_#{<%= singular_table_name %>.id}"
|
63
|
+
end
|
64
|
+
click_link I18n.t('active_admin.batch_actions.action_label', :title => 'active_admin.batch_actions.labels.destroy')
|
65
|
+
page.should_not have_content(I18n.t('active_admin.batch_actions.button_label'))
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'generators/rspec/scaffold/scaffold_generator'
|
2
|
+
require File.join(File.dirname(__FILE__), '../../active_leonardo')
|
3
|
+
|
4
|
+
module Rspec
|
5
|
+
module Generators
|
6
|
+
class LeoscaGenerator < ::Rspec::Generators::ScaffoldGenerator
|
7
|
+
include ::ActiveLeonardo::Base
|
8
|
+
include ::ActiveLeonardo::Leosca
|
9
|
+
include ::ActiveLeonardo::Test
|
10
|
+
#include ::ActiveLeonardo::Nested
|
11
|
+
#include ::ActiveLeonardo::Nested::Test
|
12
|
+
#puts 'Rspec:Generators:LeoscaGenerator'
|
13
|
+
source_paths << File.expand_path('../templates', __FILE__)
|
14
|
+
|
15
|
+
#Leonardo options
|
16
|
+
class_option :remote, :type => :boolean, :default => true, :desc => "It checks ajax sections"
|
17
|
+
class_option :under, :type => :string, :default => "", :banner => "brand/category", :desc => "Nested resources"
|
18
|
+
class_option :activespace, :type => :string, :default => "admin", :banner => ":admin", :desc => "To nest a resource under namespace(s)"
|
19
|
+
|
20
|
+
#Override
|
21
|
+
def generate_controller_spec
|
22
|
+
return unless options[:controller_specs]
|
23
|
+
|
24
|
+
template 'controller_spec.rb',
|
25
|
+
#File.join('spec/controllers', base_namespaces, controller_class_path, "#{controller_file_name}_controller_spec.rb")
|
26
|
+
File.join('spec/controllers', controller_class_path, "#{controller_file_name}_controller_spec.rb")
|
27
|
+
end
|
28
|
+
|
29
|
+
#Override
|
30
|
+
def generate_routing_spec
|
31
|
+
return unless options[:routing_specs]
|
32
|
+
|
33
|
+
template 'routing_spec.rb',
|
34
|
+
#File.join('spec/routing', base_namespaces, controller_class_path, "#{controller_file_name}_routing_spec.rb")
|
35
|
+
File.join('spec/routing', controller_class_path, "#{controller_file_name}_routing_spec.rb")
|
36
|
+
end
|
37
|
+
|
38
|
+
hook_for :integration_tool, :as => :leointegration
|
39
|
+
|
40
|
+
protected
|
41
|
+
|
42
|
+
#Override
|
43
|
+
#def copy_view(view)
|
44
|
+
# template "#{view}_spec.rb",
|
45
|
+
# File.join("spec/views", base_namespaces, controller_file_path, "#{view}.html.#{options[:template_engine]}_spec.rb")
|
46
|
+
#end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,181 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
4
|
+
# It demonstrates how one might use RSpec to specify the controller code that
|
5
|
+
# was generated by Rails when you ran the scaffold generator.
|
6
|
+
#
|
7
|
+
# It assumes that the implementation code is generated by the rails scaffold
|
8
|
+
# generator. If you are using any extension libraries to generate different
|
9
|
+
# controller code, this generated spec may or may not pass.
|
10
|
+
#
|
11
|
+
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
12
|
+
# of tools you can use to make these specs even more expressive, but we're
|
13
|
+
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
14
|
+
#
|
15
|
+
# Compared to earlier versions of this generator, there is very limited use of
|
16
|
+
# stubs and message expectations in this spec. Stubs are only used when there
|
17
|
+
# is no simpler way to get a handle on the object needed for the example.
|
18
|
+
# Message expectations are only used when there is no simpler way to specify
|
19
|
+
# that an instance is receiving a specific message.
|
20
|
+
|
21
|
+
describe <%= controller_class_name %>Controller do
|
22
|
+
|
23
|
+
<% unless options[:singleton] -%>
|
24
|
+
describe "GET index" do
|
25
|
+
it "assigns all <%= table_name.pluralize %> as @<%= table_name.pluralize %>" do
|
26
|
+
<%= "login_controller_as(:user)" if authentication? %>
|
27
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
28
|
+
get :index
|
29
|
+
assigns(:<%= table_name %>).should eq([<%= file_name %>])
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
<% end -%>
|
34
|
+
describe "GET show" do
|
35
|
+
it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
|
36
|
+
<%= "login_controller_as(:user)" if authentication? %>
|
37
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
38
|
+
get :show, :id => <%= file_name %>.id.to_s
|
39
|
+
assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "GET new" do
|
44
|
+
it "assigns a new <%= ns_file_name %> as @<%= ns_file_name %>" do
|
45
|
+
<%= "login_controller_as(:user)" if authentication? %>
|
46
|
+
get :new
|
47
|
+
assigns(:<%= ns_file_name %>).should be_a_new(<%= class_name %>)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "GET edit" do
|
52
|
+
it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
|
53
|
+
<%= "login_controller_as(:user)" if authentication? %>
|
54
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
55
|
+
get :edit, :id => <%= file_name %>.id.to_s
|
56
|
+
assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "POST create" do
|
61
|
+
describe "with valid params" do
|
62
|
+
it "creates a new <%= class_name %>" do
|
63
|
+
<%= "login_controller_as(:user)" if authentication? %>
|
64
|
+
expect {
|
65
|
+
post :create, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
|
66
|
+
}.to change(<%= class_name %>, :count).by(1)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "assigns a newly created <%= ns_file_name %> as @<%= ns_file_name %>" do
|
70
|
+
<%= "login_controller_as(:user)" if authentication? %>
|
71
|
+
post :create, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
|
72
|
+
assigns(:<%= ns_file_name %>).should be_a(<%= class_name %>)
|
73
|
+
assigns(:<%= ns_file_name %>).should be_persisted
|
74
|
+
end
|
75
|
+
|
76
|
+
it "redirects to the created <%= ns_file_name %>" do
|
77
|
+
<%= "login_controller_as(:user)" if authentication? %>
|
78
|
+
post :create, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
|
79
|
+
response.should redirect_to(<%= show_resource_path_test "#{class_name}.last" %>)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "with invalid params" do
|
84
|
+
it "assigns a newly created but unsaved <%= ns_file_name %> as @<%= ns_file_name %>" do
|
85
|
+
<%= "login_controller_as(:user)" if authentication? %>
|
86
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
87
|
+
<%= class_name %>.any_instance.stub(:save).and_return(false)
|
88
|
+
post :create, :<%= ns_file_name %> => {}
|
89
|
+
assigns(:<%= ns_file_name %>).should be_a_new(<%= class_name %>)
|
90
|
+
end
|
91
|
+
|
92
|
+
it "re-renders the 'new' template" do
|
93
|
+
<%= "login_controller_as(:user)" if authentication? %>
|
94
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
95
|
+
<%= class_name %>.any_instance.stub(:save).and_return(false)
|
96
|
+
post :create, :<%= ns_file_name %> => {}
|
97
|
+
response.should render_template("new")
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "PUT update" do
|
103
|
+
describe "with valid params" do
|
104
|
+
it "updates the requested <%= ns_file_name %>" do
|
105
|
+
<%= "login_controller_as(:user)" if authentication? %>
|
106
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
107
|
+
# Assuming there are no other <%= table_name %> in the database, this
|
108
|
+
# specifies that the <%= class_name %> created on the previous line
|
109
|
+
# receives the :update_attributes message with whatever params are
|
110
|
+
# submitted in the request.
|
111
|
+
<%= class_name %>.any_instance.should_receive(:update_attributes).with(Factory.attributes_for(:<%= file_name %>))
|
112
|
+
put :update, :id => <%= file_name %>.id, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
|
116
|
+
<%= "login_controller_as(:user)" if authentication? %>
|
117
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
118
|
+
put :update, :id => <%= file_name %>.id, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
|
119
|
+
assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "redirects to the <%= ns_file_name %>" do
|
123
|
+
<%= "login_controller_as(:user)" if authentication? %>
|
124
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
125
|
+
put :update, :id => <%= file_name %>.id, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
|
126
|
+
response.should redirect_to(<%= show_resource_path_test %>)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "with invalid params" do
|
131
|
+
it "assigns the <%= ns_file_name %> as @<%= ns_file_name %>" do
|
132
|
+
<%= "login_controller_as(:user)" if authentication? %>
|
133
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
134
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
135
|
+
<%= class_name %>.any_instance.stub(:save).and_return(false)
|
136
|
+
put :update, :id => <%= file_name %>.id.to_s, :<%= ns_file_name %> => {}
|
137
|
+
assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
|
138
|
+
end
|
139
|
+
|
140
|
+
it "re-renders the 'edit' template" do
|
141
|
+
<%= "login_controller_as(:user)" if authentication? %>
|
142
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
143
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
144
|
+
<%= class_name %>.any_instance.stub(:save).and_return(false)
|
145
|
+
put :update, :id => <%= file_name %>.id.to_s, :<%= ns_file_name %> => {}
|
146
|
+
response.should render_template("edit")
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe "DELETE destroy" do
|
152
|
+
describe "with authorization" do
|
153
|
+
it "destroys the requested <%= ns_file_name %>" do
|
154
|
+
<%= "login_controller_as(:user_manager)" if authentication? %>
|
155
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
156
|
+
expect {
|
157
|
+
delete :destroy, :id => <%= file_name %>.id.to_s
|
158
|
+
}.to change(<%= class_name %>, :count).by(-1)
|
159
|
+
end
|
160
|
+
|
161
|
+
it "redirects to the <%= table_name %> list" do
|
162
|
+
<%= "login_controller_as(:user_manager)" if authentication? %>
|
163
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
164
|
+
delete :destroy, :id => <%= file_name %>.id.to_s
|
165
|
+
response.should redirect_to(<%= list_resources_path_test %>)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
<%- if authorization? -%>
|
169
|
+
describe "without authorization" do
|
170
|
+
it "destroys the requested <%= ns_file_name %>" do
|
171
|
+
<%= "login_controller_as(:user_guest)" if authentication? %>
|
172
|
+
<%= file_name %> = Factory(:<%= file_name %>)
|
173
|
+
expect {
|
174
|
+
delete :destroy, :id => <%= file_name %>.id.to_s
|
175
|
+
}.to change(<%= class_name %>, :count).by(0)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
<%- end -%>
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
|
4
|
+
describe "<%= ns_table_name %>/edit" do
|
5
|
+
before(:each) do
|
6
|
+
@<%= ns_file_name %> = assign(:<%= ns_file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? '))' : ',' %>
|
7
|
+
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
|
8
|
+
:<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
|
9
|
+
<% end -%>
|
10
|
+
<%= output_attributes.empty? ? "" : " ))\n" -%>
|
11
|
+
end
|
12
|
+
|
13
|
+
it "renders the edit <%= ns_file_name %> form" do
|
14
|
+
render
|
15
|
+
|
16
|
+
<% if webrat? -%>
|
17
|
+
rendered.should have_selector("form", :action => <%= ns_file_name %>_path(@<%= ns_file_name %>), :method => "post") do |form|
|
18
|
+
<% for attribute in output_attributes -%>
|
19
|
+
form.should have_selector("<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]")
|
20
|
+
<% end -%>
|
21
|
+
end
|
22
|
+
<% else -%>
|
23
|
+
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
24
|
+
assert_select "form", :action => <%= index_helper %>_path(@<%= ns_file_name %>), :method => "post" do
|
25
|
+
<% for attribute in output_attributes -%>
|
26
|
+
assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]"
|
27
|
+
<% end -%>
|
28
|
+
end
|
29
|
+
<% end -%>
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
|
4
|
+
describe "<%= ns_table_name %>/index" do
|
5
|
+
before(:each) do
|
6
|
+
assign(:<%= table_name %>, [
|
7
|
+
<% [1,2].each_with_index do |id, model_index| -%>
|
8
|
+
stub_model(<%= class_name %><%= output_attributes.empty? ? (model_index == 1 ? ')' : '),') : ',' %>
|
9
|
+
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
|
10
|
+
:<%= attribute.name %> => <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
|
11
|
+
<% end -%>
|
12
|
+
<% if !output_attributes.empty? -%>
|
13
|
+
<%= model_index == 1 ? ')' : '),' %>
|
14
|
+
<% end -%>
|
15
|
+
<% end -%>
|
16
|
+
])
|
17
|
+
end
|
18
|
+
|
19
|
+
it "renders a list of <%= ns_table_name %>" do
|
20
|
+
render
|
21
|
+
<% unless webrat? -%>
|
22
|
+
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
23
|
+
<% end -%>
|
24
|
+
<% for attribute in output_attributes -%>
|
25
|
+
<% if webrat? -%>
|
26
|
+
rendered.should have_selector("tr>td", :content => <%= value_for(attribute) %>.to_s, :count => 2)
|
27
|
+
<% else -%>
|
28
|
+
assert_select "tr>td", :text => <%= value_for(attribute) %>.to_s, :count => 2
|
29
|
+
<% end -%>
|
30
|
+
<% end -%>
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
|
4
|
+
describe "<%= ns_table_name %>/new" do
|
5
|
+
before(:each) do
|
6
|
+
assign(:<%= ns_file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? ').as_new_record)' : ',' %>
|
7
|
+
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
|
8
|
+
:<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
|
9
|
+
<% end -%>
|
10
|
+
<%= !output_attributes.empty? ? " ).as_new_record)\n end" : " end" %>
|
11
|
+
|
12
|
+
it "renders new <%= ns_file_name %> form" do
|
13
|
+
render
|
14
|
+
|
15
|
+
<% if webrat? -%>
|
16
|
+
rendered.should have_selector("form", :action => <%= table_name %>_path, :method => "post") do |form|
|
17
|
+
<% for attribute in output_attributes -%>
|
18
|
+
form.should have_selector("<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]")
|
19
|
+
<% end -%>
|
20
|
+
end
|
21
|
+
<% else -%>
|
22
|
+
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
23
|
+
assert_select "form", :action => <%= index_helper %>_path, :method => "post" do
|
24
|
+
<% for attribute in output_attributes -%>
|
25
|
+
assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]"
|
26
|
+
<% end -%>
|
27
|
+
end
|
28
|
+
<% end -%>
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
<% module_namespacing do -%>
|
4
|
+
describe <%= controller_class_name %>Controller do
|
5
|
+
describe "routing" do
|
6
|
+
|
7
|
+
<% unless options[:singleton] -%>
|
8
|
+
it "routes to #index" do
|
9
|
+
get("/<%= options[:activespace] %>/<%= ns_table_name %>").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#index")
|
10
|
+
end
|
11
|
+
|
12
|
+
<% end -%>
|
13
|
+
it "routes to #new" do
|
14
|
+
get("/<%= options[:activespace] %>/<%= ns_table_name %>/new").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#new")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "routes to #show" do
|
18
|
+
get("/<%= options[:activespace] %>/<%= ns_table_name %>/1").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#show", :id => "1")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "routes to #edit" do
|
22
|
+
get("/<%= options[:activespace] %>/<%= ns_table_name %>/1/edit").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#edit", :id => "1")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "routes to #create" do
|
26
|
+
post("/<%= options[:activespace] %>/<%= ns_table_name %>").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#create")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "routes to #update" do
|
30
|
+
put("/<%= options[:activespace] %>/<%= ns_table_name %>/1").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#update", :id => "1")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "routes to #destroy" do
|
34
|
+
delete("/<%= options[:activespace] %>/<%= ns_table_name %>/1").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#destroy", :id => "1")
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
<% end -%>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
|
4
|
+
describe "<%= ns_table_name %>/show" do
|
5
|
+
before(:each) do
|
6
|
+
@<%= ns_file_name %> = assign(:<%= ns_file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? '))' : ',' %>
|
7
|
+
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
|
8
|
+
:<%= attribute.name %> => <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
|
9
|
+
<% end -%>
|
10
|
+
<% if !output_attributes.empty? -%>
|
11
|
+
))
|
12
|
+
<% end -%>
|
13
|
+
end
|
14
|
+
|
15
|
+
it "renders attributes in <p>" do
|
16
|
+
render
|
17
|
+
<% unless webrat? -%>
|
18
|
+
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
19
|
+
<% end -%>
|
20
|
+
<% for attribute in output_attributes -%>
|
21
|
+
<% if webrat? -%>
|
22
|
+
rendered.should contain(<%= value_for(attribute) %>.to_s)
|
23
|
+
<% else -%>
|
24
|
+
rendered.should match(/<%= eval(value_for(attribute)) %>/)
|
25
|
+
<% end -%>
|
26
|
+
<% end -%>
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_leonardo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 746539005
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
|
9
|
+
- 6
|
10
|
+
- beta
|
11
|
+
- 1
|
12
|
+
version: 0.0.6.beta1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Marco Mastrodonato
|
@@ -15,7 +17,7 @@ autorequire:
|
|
15
17
|
bindir: bin
|
16
18
|
cert_chain: []
|
17
19
|
|
18
|
-
date:
|
20
|
+
date: 2013-01-03 00:00:00 Z
|
19
21
|
dependencies:
|
20
22
|
- !ruby/object:Gem::Dependency
|
21
23
|
name: rails
|
@@ -41,12 +43,20 @@ dependencies:
|
|
41
43
|
requirements:
|
42
44
|
- - ">="
|
43
45
|
- !ruby/object:Gem::Version
|
44
|
-
hash:
|
46
|
+
hash: 11
|
45
47
|
segments:
|
46
48
|
- 0
|
47
|
-
-
|
49
|
+
- 5
|
50
|
+
- 0
|
51
|
+
version: 0.5.0
|
52
|
+
- - <
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
hash: 7
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
- 6
|
48
58
|
- 0
|
49
|
-
version: 0.
|
59
|
+
version: 0.6.0
|
50
60
|
type: :runtime
|
51
61
|
version_requirements: *id002
|
52
62
|
- !ruby/object:Gem::Dependency
|
@@ -57,12 +67,12 @@ dependencies:
|
|
57
67
|
requirements:
|
58
68
|
- - ">="
|
59
69
|
- !ruby/object:Gem::Version
|
60
|
-
hash:
|
70
|
+
hash: 15
|
61
71
|
segments:
|
62
72
|
- 1
|
63
|
-
-
|
73
|
+
- 6
|
64
74
|
- 0
|
65
|
-
version: 1.
|
75
|
+
version: 1.6.0
|
66
76
|
type: :runtime
|
67
77
|
version_requirements: *id003
|
68
78
|
- !ruby/object:Gem::Dependency
|
@@ -98,13 +108,17 @@ files:
|
|
98
108
|
- lib/generators/leolay/templates/app/admin/users.rb
|
99
109
|
- lib/generators/leolay/templates/app/assets/javascripts/custom.js
|
100
110
|
- lib/generators/leolay/templates/app/helpers/layout_helper.rb
|
111
|
+
- lib/generators/leolay/templates/config/config.yml
|
101
112
|
- lib/generators/leolay/templates/config/initializers/activeadmin_leonardo.rb
|
113
|
+
- lib/generators/leolay/templates/config/initializers/config.rb
|
102
114
|
- lib/generators/leolay/templates/config/locales/devise.it.yml
|
103
115
|
- lib/generators/leolay/templates/config/locales/en.yml
|
104
116
|
- lib/generators/leolay/templates/config/locales/it.yml
|
105
|
-
- lib/generators/leolay/templates/config.rb
|
106
117
|
- lib/generators/leolay/templates/lib/development_mail_interceptor.rb
|
107
118
|
- lib/generators/leolay/templates/lib/upd_array.rb
|
119
|
+
- lib/generators/leolay/templates/spec/factories.rb
|
120
|
+
- lib/generators/leolay/templates/spec/helpers/application_helpers_spec.rb
|
121
|
+
- lib/generators/leolay/templates/spec/support/devise.rb
|
108
122
|
- lib/generators/leolay/templates/styles/active/images/logo.png
|
109
123
|
- lib/generators/leolay/templates/styles/active/images/style/ico_v.png
|
110
124
|
- lib/generators/leolay/templates/styles/active/images/style/ico_x.png
|
@@ -124,6 +138,15 @@ files:
|
|
124
138
|
- lib/generators/rails/leosca_controller/leosca_controller_generator.rb
|
125
139
|
- lib/generators/rails/leosca_controller/templates/controller.rb
|
126
140
|
- lib/generators/rails/leosca_controller/USAGE
|
141
|
+
- lib/generators/rspec/leointegration/leointegration_generator.rb
|
142
|
+
- lib/generators/rspec/leointegration/templates/request_spec.rb
|
143
|
+
- lib/generators/rspec/leosca/leosca_generator.rb
|
144
|
+
- lib/generators/rspec/leosca/templates/controller_spec.rb
|
145
|
+
- lib/generators/rspec/leosca/templates/edit_spec.rb
|
146
|
+
- lib/generators/rspec/leosca/templates/index_spec.rb
|
147
|
+
- lib/generators/rspec/leosca/templates/new_spec.rb
|
148
|
+
- lib/generators/rspec/leosca/templates/routing_spec.rb
|
149
|
+
- lib/generators/rspec/leosca/templates/show_spec.rb
|
127
150
|
- LICENSE
|
128
151
|
- README.rdoc
|
129
152
|
- CHANGELOG
|
@@ -148,12 +171,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
148
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
172
|
none: false
|
150
173
|
requirements:
|
151
|
-
- - "
|
174
|
+
- - ">"
|
152
175
|
- !ruby/object:Gem::Version
|
153
|
-
hash:
|
176
|
+
hash: 25
|
154
177
|
segments:
|
155
|
-
-
|
156
|
-
|
178
|
+
- 1
|
179
|
+
- 3
|
180
|
+
- 1
|
181
|
+
version: 1.3.1
|
157
182
|
requirements:
|
158
183
|
- Start a new app with the active_template.rb inside root folder
|
159
184
|
rubyforge_project:
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# Put here application's params
|
2
|
-
|
3
|
-
CONFIG = {
|
4
|
-
:application => {
|
5
|
-
:name => "<%= app_name %>",
|
6
|
-
:version => "0.0.1",
|
7
|
-
:started_at => "<%= Time.now.strftime('%d/%m/%Y') %>",
|
8
|
-
:updated_at => "<%= Time.now.strftime('%d/%m/%Y') %>"
|
9
|
-
},
|
10
|
-
:default_style => "<%= style_name %>"
|
11
|
-
}
|