active_leonardo 0.0.6.beta1 → 0.0.6.beta2

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.
Files changed (22) hide show
  1. data/active_template.rb +8 -2
  2. data/lib/generators/active_leonardo.rb +1 -1
  3. data/lib/generators/leolay/leolay_generator.rb +19 -10
  4. data/lib/generators/leolay/templates/app/assets/javascripts/custom.js.coffee +2 -0
  5. data/lib/generators/leolay/templates/spec/helpers/{application_helpers_spec.rb → application_helpers.rb} +1 -1
  6. data/lib/generators/leolay/templates/styles/active/stylesheets/app/stylesheet.css.scss +3 -1
  7. data/lib/generators/leolay/templates/styles/active/views/layout/_session.html.erb +1 -1
  8. data/lib/generators/rspec/leointegration/leointegration_generator.rb +5 -2
  9. data/lib/generators/rspec/leointegration/templates/admin/feature.rb +67 -0
  10. data/lib/generators/rspec/leointegration/templates/feature.rb +9 -0
  11. data/lib/generators/rspec/leosca/leosca_generator.rb +8 -0
  12. data/lib/generators/rspec/leosca/templates/admin/controller_spec.rb +181 -0
  13. data/lib/generators/rspec/leosca/templates/admin/edit_spec.rb +31 -0
  14. data/lib/generators/rspec/leosca/templates/admin/index_spec.rb +32 -0
  15. data/lib/generators/rspec/leosca/templates/admin/new_spec.rb +30 -0
  16. data/lib/generators/rspec/leosca/templates/admin/routing_spec.rb +39 -0
  17. data/lib/generators/rspec/leosca/templates/admin/show_spec.rb +28 -0
  18. data/lib/generators/rspec/leosca/templates/controller_spec.rb +51 -64
  19. data/lib/generators/rspec/leosca/templates/routing_spec.rb +7 -7
  20. metadata +14 -7
  21. data/lib/generators/leolay/templates/app/assets/javascripts/custom.js +0 -10
  22. data/lib/generators/rspec/leointegration/templates/request_spec.rb +0 -70
data/active_template.rb CHANGED
@@ -38,6 +38,10 @@ if use_git
38
38
  EOS
39
39
  end
40
40
 
41
+ gem "rack-mini-profiler"
42
+ gem "turbolinks"
43
+ gem "jquery-turbolinks"
44
+
41
45
  gem "activeadmin"
42
46
  gem "active_admin_editor"
43
47
  gem "meta_search"
@@ -125,7 +129,9 @@ rake "db:migrate"
125
129
  rake "db:seed"
126
130
 
127
131
  #rake "gems:unpack" if yes?("Unpack to vendor/gems ?")
128
-
129
- git :add => ".", :commit => "-m 'initial commit'" if use_git
132
+ if use_git
133
+ git :add => "."
134
+ git :commit => %Q{ -m 'Initial commit' }
135
+ end
130
136
 
131
137
  puts "ENJOY!"
@@ -360,7 +360,7 @@ module ActiveLeonardo
360
360
  #product => "[:activespace, product]"
361
361
  def show_resource_path_test(resource=nil)
362
362
  resource ||= singular_table_name
363
- "[:#{get_activespace}, #{resource}]"
363
+ "[:#{options[:activespace]}, #{resource}]"
364
364
  end
365
365
 
366
366
  #product => new_activespace_product_path
@@ -97,7 +97,7 @@ class LeolayGenerator < Rails::Generators::Base
97
97
  def setup_application
98
98
  application do
99
99
  <<-FILE.gsub(/^ /, '')
100
- config.generators do |g|
100
+ config.generators do |g|
101
101
  g.stylesheets false
102
102
  g.javascripts true
103
103
  g.leosca_controller :leosca_controller
@@ -245,25 +245,34 @@ class LeolayGenerator < Rails::Generators::Base
245
245
  def setup_javascript
246
246
  app_path = "app/assets/javascripts"
247
247
 
248
- file = "#{app_path}/custom.js"
248
+ file = "#{app_path}/custom.js.coffee"
249
249
  copy_file file, file
250
250
 
251
- file = "#{app_path}/application.js"
252
- append_file file do
251
+ file = "#{app_path}/active_admin.js"
252
+ gsub_file file, "//= require active_admin/base" do
253
+ <<-FILE.gsub(/^ /, '')
254
+ //= require jquery
255
+ //= require jquery-ui
256
+ //= require jquery_ujs
257
+ //= require turbolinks
258
+ //= require jquery.turbolinks
259
+
260
+ //= require active_admin/base
261
+ FILE
262
+ end
263
+ inject_into_file file, :before => "\n//= require active_admin/base" do
253
264
  <<-FILE.gsub(/^ /, '')
265
+ #{options[:auth_class].downcase} ||= #{auth_class}.new
266
+ can :manage, :all if #{options[:auth_class].downcase}.role? :admin
254
267
 
255
- //= require custom
256
268
  FILE
257
269
  end
258
-
259
- file = "#{app_path}/active_admin.js"
260
270
  append_file file do
261
271
  <<-FILE.gsub(/^ /, '')
262
272
 
263
273
  //= require custom
264
274
  FILE
265
275
  end
266
-
267
276
  end
268
277
 
269
278
  #def setup_stylesheets
@@ -306,7 +315,7 @@ class LeolayGenerator < Rails::Generators::Base
306
315
  <<-FILE.gsub(/^ /, '')
307
316
 
308
317
  require 'capybara/rspec'
309
- require 'helpers/application_helpers_spec'
318
+ require 'helpers/application_helpers'
310
319
 
311
320
  Capybara.default_wait_time = 10 #default=2
312
321
  FILE
@@ -339,7 +348,7 @@ class LeolayGenerator < Rails::Generators::Base
339
348
  copy_file file, file
340
349
  file = "spec/support/devise.rb"
341
350
  copy_file file, file
342
- file = "spec/helpers/application_helpers_spec.rb"
351
+ file = "spec/helpers/application_helpers.rb"
343
352
  copy_file file, file
344
353
 
345
354
  end
@@ -0,0 +1,2 @@
1
+ # ActiveLeonardo
2
+ # Use this file to add your javascript
@@ -3,7 +3,7 @@ module ApplicationHelpers
3
3
  user = Factory(role)
4
4
  fill_in 'user_email', :with => user.email
5
5
  fill_in 'user_password', :with => user.password
6
- click_button 'Sign in'
6
+ click_button 'Login'
7
7
  end
8
8
  def login_controller_as(role=:user)
9
9
  user = Factory(role)
@@ -1,7 +1,9 @@
1
1
  @import "active_admin/mixins";
2
2
  @import "active_admin/base";
3
3
  @import "enviroment";
4
- @import "active_admin/pages/logged_out";
4
+ #body {
5
+ @import "active_admin/pages/logged_out";
6
+ }
5
7
 
6
8
  #header {
7
9
  #session {
@@ -3,7 +3,7 @@
3
3
  <%= t("authentication.signed_in_as") %> <strong><%= current_user.email || "Guest" %></strong>. <%= t("authentication.not_you") %>
4
4
  <%= link_to t("authentication.sign_out"), destroy_user_session_path, :method => :delete %>
5
5
  <%- else -%>
6
- <%= link_to t("authentication.sign_up"), new_user_registration_path %> -
6
+ <%#= link_to t("authentication.sign_up"), new_user_registration_path %> -
7
7
  <%= link_to t("authentication.sign_in"), new_user_session_path %>
8
8
  <%- end -%>
9
9
  </div>
@@ -22,9 +22,12 @@ module Rspec
22
22
  def generate_request_spec
23
23
  return unless options[:request_specs]
24
24
 
25
- template 'request_spec.rb',
25
+ template 'feature.rb',
26
26
  #File.join('spec/requests', class_path, base_namespaces, "#{table_name}_spec.rb")
27
- File.join('spec/requests', class_path, "#{table_name}_spec.rb")
27
+ File.join('spec/features', class_path, "#{table_name}.rb")
28
+ template "#{options[:activespace]}/feature.rb",
29
+ #File.join('spec/requests', class_path, base_namespaces, "#{table_name}_spec.rb")
30
+ File.join('spec/features', options[:activespace], class_path, "#{table_name}.rb")
28
31
  end
29
32
 
30
33
  end
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+ <%- check_attr_to_have, check_attr_to_not_have = get_attr_to_match -%>
3
+
4
+ feature "<%= options[:activespace].classify %>::<%= class_name.pluralize %>" do
5
+ scenario "displays <%= plural_table_name %>" do
6
+ <%= singular_table_name %> = Factory(:<%= singular_table_name %>)
7
+ visit <%= list_resources_path_test %>
8
+ <%= "login_view_as(:user_guest)" if authentication? -%>
9
+ #save_and_open_page #uncomment to debug
10
+ page.should <%= check_attr_to_have %>
11
+ assert page.find("tr#<%= singular_table_name %>_#{<%= singular_table_name %>.id}").visible?
12
+ end
13
+
14
+ scenario "creates a new <%= singular_table_name %>" do
15
+ <%= singular_table_name %> = Factory.build(:<%= singular_table_name %>)
16
+ visit <%= new_resource_path_test %>
17
+ <%= "login_view_as(:user_admin)" if authentication? %>
18
+ <%= fill_form_with_values.join(CRLF) %>
19
+ click_button "Create #{I18n.t('models.<%= singular_table_name %>')}"
20
+ #save_and_open_page #uncomment to debug
21
+ page.should have_content(I18n.t(:created, :model => I18n.t('models.<%= singular_table_name %>')))
22
+ page.should <%= check_attr_to_have %>
23
+ end
24
+
25
+ scenario "edit a <%= singular_table_name %>" do
26
+ <%= singular_table_name %> = Factory(:<%= singular_table_name %>)
27
+ visit <%= list_resources_path_test %>
28
+ <%= "login_view_as(:user_manager)" if authentication? -%>
29
+ #save_and_open_page #uncomment to debug
30
+ page.should <%= check_attr_to_have %>
31
+ assert page.find("tr#<%= singular_table_name %>_#{<%= singular_table_name %>.id}").visible?
32
+ check("check#{<%= singular_table_name %>.id}")
33
+ click_link I18n.t(:edit)
34
+ page.should have_content(I18n.t(:edit))
35
+ <%= fill_form_with_values("#{plural_table_name}_#_name").join(CRLF) %>
36
+ click_button I18n.t(:submit)
37
+ page.should have_content(I18n.t(:show))
38
+ end
39
+
40
+ scenario "destroy one <%= singular_table_name %>" do
41
+ <%= singular_table_name %> = Factory(:<%= singular_table_name %>)
42
+ visit <%= list_resources_path_test %>
43
+ <%= "login_view_as(:user_manager)" if authentication? -%>
44
+ #save_and_open_page #uncomment to debug
45
+ page.should <%= check_attr_to_have %>
46
+ assert page.find("tr#<%= singular_table_name %>_#{<%= singular_table_name %>.id}").visible?
47
+ click_link I18n.t(:delete)
48
+ #page.should have_no_content("<%= singular_table_name %>#{<%= singular_table_name %>.id}")
49
+ assert_not page.find("tr#<%= singular_table_name %>_#{<%= singular_table_name %>.id}")
50
+ end
51
+
52
+ scenario "destroy several <%= plural_table_name %>", :js => true do
53
+ <%= plural_table_name %> = FactoryGirl.create_list(:<%= singular_table_name %>, 2)
54
+ visit <%= list_resources_path_test %>
55
+ <%= "login_view_as(:user_manager)" if authentication? -%>
56
+ #save_and_open_page #uncomment to debug
57
+ <%= plural_table_name %>.each do |<%= singular_table_name %>|
58
+ page.should <%= check_attr_to_have %>
59
+ assert page.find("tr#<%= singular_table_name %>_#{<%= singular_table_name %>.id}").visible?
60
+ check "batch_action_item_#{<%= singular_table_name %>.id}"
61
+ end
62
+ click_link I18n.t('active_admin.batch_actions.action_label', :title => 'active_admin.batch_actions.labels.destroy')
63
+ <%= plural_table_name %>.each do |<%= singular_table_name %>|
64
+ page.should_not <%= check_attr_to_have %>
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ feature "<%= class_name.pluralize %>" do
4
+ scenario "When visit the index i should see some <%= plural_table_name %>" do
5
+ # Write some real scenario
6
+ visit <%= index_helper %>_path
7
+ response.status.should be(200)
8
+ end
9
+ end
@@ -24,6 +24,10 @@ module Rspec
24
24
  template 'controller_spec.rb',
25
25
  #File.join('spec/controllers', base_namespaces, controller_class_path, "#{controller_file_name}_controller_spec.rb")
26
26
  File.join('spec/controllers', controller_class_path, "#{controller_file_name}_controller_spec.rb")
27
+
28
+ template "#{options[:activespace]}/controller_spec.rb",
29
+ #File.join('spec/controllers', base_namespaces, controller_class_path, "#{controller_file_name}_controller_spec.rb")
30
+ File.join('spec/controllers', options[:activespace], controller_class_path, "#{controller_file_name}_controller_spec.rb")
27
31
  end
28
32
 
29
33
  #Override
@@ -33,6 +37,10 @@ module Rspec
33
37
  template 'routing_spec.rb',
34
38
  #File.join('spec/routing', base_namespaces, controller_class_path, "#{controller_file_name}_routing_spec.rb")
35
39
  File.join('spec/routing', controller_class_path, "#{controller_file_name}_routing_spec.rb")
40
+
41
+ template "#{options[:activespace]}/routing_spec.rb",
42
+ #File.join('spec/routing', base_namespaces, controller_class_path, "#{controller_file_name}_routing_spec.rb")
43
+ File.join('spec/routing', options[:activespace], controller_class_path, "#{controller_file_name}_routing_spec.rb")
36
44
  end
37
45
 
38
46
  hook_for :integration_tool, :as => :leointegration
@@ -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 <%= options[:activespace].classify %>::<%= 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
@@ -18,14 +18,28 @@ require 'spec_helper'
18
18
  # Message expectations are only used when there is no simpler way to specify
19
19
  # that an instance is receiving a specific message.
20
20
 
21
+ <% module_namespacing do -%>
21
22
  describe <%= controller_class_name %>Controller do
22
23
 
24
+ # This should return the minimal set of attributes required to create a valid
25
+ # <%= class_name %>. As you add validations to <%= class_name %>, be sure to
26
+ # update the return value of this method accordingly.
27
+ def valid_attributes
28
+ <%= formatted_hash(example_valid_attributes) %>
29
+ end
30
+
31
+ # This should return the minimal set of values that should be in the session
32
+ # in order to pass any filters (e.g. authentication) defined in
33
+ # <%= controller_class_name %>Controller. Be sure to keep this updated too.
34
+ def valid_session
35
+ {}
36
+ end
37
+
23
38
  <% unless options[:singleton] -%>
24
39
  describe "GET index" do
25
40
  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
41
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
42
+ get :index, {}, valid_session
29
43
  assigns(:<%= table_name %>).should eq([<%= file_name %>])
30
44
  end
31
45
  end
@@ -33,26 +47,23 @@ describe <%= controller_class_name %>Controller do
33
47
  <% end -%>
34
48
  describe "GET show" do
35
49
  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
50
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
51
+ get :show, {:id => <%= file_name %>.to_param}, valid_session
39
52
  assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
40
53
  end
41
54
  end
42
55
 
43
56
  describe "GET new" do
44
57
  it "assigns a new <%= ns_file_name %> as @<%= ns_file_name %>" do
45
- <%= "login_controller_as(:user)" if authentication? %>
46
- get :new
58
+ get :new, {}, valid_session
47
59
  assigns(:<%= ns_file_name %>).should be_a_new(<%= class_name %>)
48
60
  end
49
61
  end
50
62
 
51
63
  describe "GET edit" do
52
64
  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
65
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
66
+ get :edit, {:id => <%= file_name %>.to_param}, valid_session
56
67
  assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
57
68
  end
58
69
  end
@@ -60,40 +71,35 @@ describe <%= controller_class_name %>Controller do
60
71
  describe "POST create" do
61
72
  describe "with valid params" do
62
73
  it "creates a new <%= class_name %>" do
63
- <%= "login_controller_as(:user)" if authentication? %>
64
74
  expect {
65
- post :create, :<%= ns_file_name %> => Factory.attributes_for(:<%= file_name %>)
75
+ post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
66
76
  }.to change(<%= class_name %>, :count).by(1)
67
77
  end
68
78
 
69
79
  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 %>)
80
+ post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
72
81
  assigns(:<%= ns_file_name %>).should be_a(<%= class_name %>)
73
82
  assigns(:<%= ns_file_name %>).should be_persisted
74
83
  end
75
84
 
76
85
  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" %>)
86
+ post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
87
+ response.should redirect_to(<%= class_name %>.last)
80
88
  end
81
89
  end
82
90
 
83
91
  describe "with invalid params" do
84
92
  it "assigns a newly created but unsaved <%= ns_file_name %> as @<%= ns_file_name %>" do
85
- <%= "login_controller_as(:user)" if authentication? %>
86
93
  # Trigger the behavior that occurs when invalid params are submitted
87
94
  <%= class_name %>.any_instance.stub(:save).and_return(false)
88
- post :create, :<%= ns_file_name %> => {}
95
+ post :create, {:<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
89
96
  assigns(:<%= ns_file_name %>).should be_a_new(<%= class_name %>)
90
97
  end
91
98
 
92
99
  it "re-renders the 'new' template" do
93
- <%= "login_controller_as(:user)" if authentication? %>
94
100
  # Trigger the behavior that occurs when invalid params are submitted
95
101
  <%= class_name %>.any_instance.stub(:save).and_return(false)
96
- post :create, :<%= ns_file_name %> => {}
102
+ post :create, {:<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
97
103
  response.should render_template("new")
98
104
  end
99
105
  end
@@ -102,80 +108,61 @@ describe <%= controller_class_name %>Controller do
102
108
  describe "PUT update" do
103
109
  describe "with valid params" do
104
110
  it "updates the requested <%= ns_file_name %>" do
105
- <%= "login_controller_as(:user)" if authentication? %>
106
- <%= file_name %> = Factory(:<%= file_name %>)
111
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
107
112
  # Assuming there are no other <%= table_name %> in the database, this
108
113
  # specifies that the <%= class_name %> created on the previous line
109
114
  # receives the :update_attributes message with whatever params are
110
115
  # 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 %>)
116
+ <%= class_name %>.any_instance.should_receive(:update_attributes).with(<%= formatted_hash(example_params_for_update) %>)
117
+ put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_params_for_update) %>}, valid_session
113
118
  end
114
119
 
115
120
  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 %>)
121
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
122
+ put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
119
123
  assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
120
124
  end
121
125
 
122
126
  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
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
128
+ put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
129
+ response.should redirect_to(<%= file_name %>)
127
130
  end
128
131
  end
129
132
 
130
133
  describe "with invalid params" do
131
134
  it "assigns the <%= ns_file_name %> as @<%= ns_file_name %>" do
132
- <%= "login_controller_as(:user)" if authentication? %>
133
- <%= file_name %> = Factory(:<%= file_name %>)
135
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
134
136
  # Trigger the behavior that occurs when invalid params are submitted
135
137
  <%= class_name %>.any_instance.stub(:save).and_return(false)
136
- put :update, :id => <%= file_name %>.id.to_s, :<%= ns_file_name %> => {}
138
+ put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
137
139
  assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
138
140
  end
139
141
 
140
142
  it "re-renders the 'edit' template" do
141
- <%= "login_controller_as(:user)" if authentication? %>
142
- <%= file_name %> = Factory(:<%= file_name %>)
143
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
143
144
  # Trigger the behavior that occurs when invalid params are submitted
144
145
  <%= class_name %>.any_instance.stub(:save).and_return(false)
145
- put :update, :id => <%= file_name %>.id.to_s, :<%= ns_file_name %> => {}
146
+ put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
146
147
  response.should render_template("edit")
147
148
  end
148
149
  end
149
150
  end
150
151
 
151
152
  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
153
+ it "destroys the requested <%= ns_file_name %>" do
154
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
155
+ expect {
156
+ delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
157
+ }.to change(<%= class_name %>, :count).by(-1)
167
158
  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
159
+
160
+ it "redirects to the <%= table_name %> list" do
161
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
162
+ delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
163
+ response.should redirect_to(<%= index_helper %>_url)
177
164
  end
178
- <%- end -%>
179
165
  end
180
166
 
181
167
  end
168
+ <% end -%>
@@ -6,32 +6,32 @@ describe <%= controller_class_name %>Controller do
6
6
 
7
7
  <% unless options[:singleton] -%>
8
8
  it "routes to #index" do
9
- get("/<%= options[:activespace] %>/<%= ns_table_name %>").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#index")
9
+ get("/<%= ns_table_name %>").should route_to("<%= ns_table_name %>#index")
10
10
  end
11
11
 
12
12
  <% end -%>
13
13
  it "routes to #new" do
14
- get("/<%= options[:activespace] %>/<%= ns_table_name %>/new").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#new")
14
+ get("/<%= ns_table_name %>/new").should route_to("<%= ns_table_name %>#new")
15
15
  end
16
16
 
17
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")
18
+ get("/<%= ns_table_name %>/1").should route_to("<%= ns_table_name %>#show", :id => "1")
19
19
  end
20
20
 
21
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")
22
+ get("/<%= ns_table_name %>/1/edit").should route_to("<%= ns_table_name %>#edit", :id => "1")
23
23
  end
24
24
 
25
25
  it "routes to #create" do
26
- post("/<%= options[:activespace] %>/<%= ns_table_name %>").should route_to("<%= options[:activespace] %>/<%= ns_table_name %>#create")
26
+ post("/<%= ns_table_name %>").should route_to("<%= ns_table_name %>#create")
27
27
  end
28
28
 
29
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")
30
+ put("/<%= ns_table_name %>/1").should route_to("<%= ns_table_name %>#update", :id => "1")
31
31
  end
32
32
 
33
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")
34
+ delete("/<%= ns_table_name %>/1").should route_to("<%= ns_table_name %>#destroy", :id => "1")
35
35
  end
36
36
 
37
37
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_leonardo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 746539005
4
+ hash: -335274718
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
9
  - 6
10
10
  - beta
11
- - 1
12
- version: 0.0.6.beta1
11
+ - 2
12
+ version: 0.0.6.beta2
13
13
  platform: ruby
14
14
  authors:
15
15
  - Marco Mastrodonato
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2013-01-03 00:00:00 Z
20
+ date: 2013-01-10 00:00:00 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails
@@ -106,7 +106,7 @@ files:
106
106
  - lib/generators/leolay/install_generator.rb
107
107
  - lib/generators/leolay/leolay_generator.rb
108
108
  - lib/generators/leolay/templates/app/admin/users.rb
109
- - lib/generators/leolay/templates/app/assets/javascripts/custom.js
109
+ - lib/generators/leolay/templates/app/assets/javascripts/custom.js.coffee
110
110
  - lib/generators/leolay/templates/app/helpers/layout_helper.rb
111
111
  - lib/generators/leolay/templates/config/config.yml
112
112
  - lib/generators/leolay/templates/config/initializers/activeadmin_leonardo.rb
@@ -117,7 +117,7 @@ files:
117
117
  - lib/generators/leolay/templates/lib/development_mail_interceptor.rb
118
118
  - lib/generators/leolay/templates/lib/upd_array.rb
119
119
  - lib/generators/leolay/templates/spec/factories.rb
120
- - lib/generators/leolay/templates/spec/helpers/application_helpers_spec.rb
120
+ - lib/generators/leolay/templates/spec/helpers/application_helpers.rb
121
121
  - lib/generators/leolay/templates/spec/support/devise.rb
122
122
  - lib/generators/leolay/templates/styles/active/images/logo.png
123
123
  - lib/generators/leolay/templates/styles/active/images/style/ico_v.png
@@ -139,8 +139,15 @@ files:
139
139
  - lib/generators/rails/leosca_controller/templates/controller.rb
140
140
  - lib/generators/rails/leosca_controller/USAGE
141
141
  - lib/generators/rspec/leointegration/leointegration_generator.rb
142
- - lib/generators/rspec/leointegration/templates/request_spec.rb
142
+ - lib/generators/rspec/leointegration/templates/admin/feature.rb
143
+ - lib/generators/rspec/leointegration/templates/feature.rb
143
144
  - lib/generators/rspec/leosca/leosca_generator.rb
145
+ - lib/generators/rspec/leosca/templates/admin/controller_spec.rb
146
+ - lib/generators/rspec/leosca/templates/admin/edit_spec.rb
147
+ - lib/generators/rspec/leosca/templates/admin/index_spec.rb
148
+ - lib/generators/rspec/leosca/templates/admin/new_spec.rb
149
+ - lib/generators/rspec/leosca/templates/admin/routing_spec.rb
150
+ - lib/generators/rspec/leosca/templates/admin/show_spec.rb
144
151
  - lib/generators/rspec/leosca/templates/controller_spec.rb
145
152
  - lib/generators/rspec/leosca/templates/edit_spec.rb
146
153
  - lib/generators/rspec/leosca/templates/index_spec.rb
@@ -1,10 +0,0 @@
1
- // Leonardo
2
- // Use this file to add your javascript
3
-
4
- $(document).ready(function() {
5
- //Add this class to an input form to auto submit on change
6
- $('.autosubmit').live('change', function() {
7
- setTimeout("$('#"+this.id+"').parents('form:first').submit();", 300);
8
- return false;
9
- });
10
- });
@@ -1,70 +0,0 @@
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