forge-cli 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +6 -14
- data/bin/cucumber +16 -0
- data/bin/erubis +16 -0
- data/bin/htmldiff +16 -0
- data/bin/ldiff +16 -0
- data/bin/rackup +16 -0
- data/bin/rake +16 -0
- data/bin/rdoc +16 -0
- data/bin/ri +16 -0
- data/bin/sprockets +16 -0
- data/bin/thor +16 -0
- data/bin/tilt +16 -0
- data/bin/tt +16 -0
- data/lib/forge-cli/modules/base/manifest.yml +18 -0
- data/lib/forge-cli/modules/base/routes.rb +1 -2
- data/lib/forge-cli/modules/events/routes.rb +6 -1
- data/lib/forge-cli/version.rb +1 -1
- data/lib/forge/Gemfile +2 -0
- data/lib/forge/app/controllers/events_controller.rb +11 -0
- data/lib/forge/app/controllers/pages_controller.rb +1 -1
- data/lib/forge/app/controllers/products_controller.rb +1 -1
- data/lib/forge/app/views/forge/dispatches/_form.html.haml +0 -13
- data/lib/forge/app/views/forge/events/_form.html.haml +14 -10
- data/lib/forge/app/views/forge/posts/_form.html.haml +2 -2
- data/lib/forge/app/views/forge/products/_form.html.haml +10 -4
- data/lib/forge/config/routes.rb +8 -3
- data/lib/forge/features/authentication.feature +8 -0
- data/lib/forge/features/step_definitions/web_steps.rb +24 -0
- data/lib/forge/features/support/env.rb +60 -0
- data/lib/forge/features/support/paths.rb +20 -0
- data/lib/forge/lib/assets/javascripts/forge/features/asset_uploads.js.erb +1 -1
- data/lib/forge/lib/generators/forge/scaffold/templates/controller_spec.rb +48 -48
- data/lib/forge/lib/generators/forge/scaffold_small/templates/controller_spec.rb +42 -42
- data/lib/forge/spec/controllers/forge/banners_controller_spec.rb +47 -47
- data/lib/forge/spec/controllers/forge/dispatches_controller_spec.rb +45 -45
- data/lib/forge/spec/controllers/forge/events_controller_spec.rb +45 -45
- data/lib/forge/spec/controllers/forge/galleries_controller_spec.rb +44 -44
- data/lib/forge/spec/controllers/forge/orders_controller_spec.rb +45 -45
- data/lib/forge/spec/controllers/forge/pages_controller_spec.rb +46 -46
- data/lib/forge/spec/controllers/forge/post_categories_controller_spec.rb +41 -41
- data/lib/forge/spec/controllers/forge/posts_controller_spec.rb +45 -45
- data/lib/forge/spec/controllers/forge/product_categories_controller_spec.rb +42 -42
- data/lib/forge/spec/controllers/forge/products_controller_spec.rb +47 -47
- data/lib/forge/spec/controllers/forge/sales_controller_spec.rb +45 -45
- data/lib/forge/spec/controllers/forge/subscriber_groups_controller_spec.rb +45 -45
- data/lib/forge/spec/controllers/forge/subscribers_controller_spec.rb +40 -40
- data/lib/forge/spec/controllers/forge/tax_rates_controller_spec.rb +41 -41
- data/lib/forge/spec/controllers/forge/users_controller_spec.rb +58 -58
- data/lib/forge/spec/controllers/forge/videos_controller_spec.rb +9 -9
- data/lib/forge/spec/models/reorderable_spec.rb +5 -5
- metadata +31 -21
- data/lib/forge/config/database.yml +0 -24
- data/lib/forge/config/deploy.rb +0 -53
- data/lib/forge/config/dispatch_daemon.yml +0 -23
- data/lib/forge/config/s3.yml +0 -19
- data/lib/forge/log/development.log +0 -2
- data/lib/forge/script/dispatch_daemon_fetcher +0 -28
@@ -0,0 +1,24 @@
|
|
1
|
+
# Multi-line step scoper
|
2
|
+
When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
|
3
|
+
with_scope(parent) { When "#{step}:", table_or_string }
|
4
|
+
end
|
5
|
+
|
6
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
7
|
+
visit path_to(page_name)
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
11
|
+
visit path_to(page_name)
|
12
|
+
end
|
13
|
+
|
14
|
+
When /^(?:|I )press "([^"]*)"$/ do |button|
|
15
|
+
click_button(button)
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^(?:|I )follow "([^"]*)"$/ do |link|
|
19
|
+
click_link(link)
|
20
|
+
end
|
21
|
+
|
22
|
+
Then /^I should see an error$/ do
|
23
|
+
(400 .. 599).should include(page.status_code)
|
24
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
2
|
+
# It is recommended to regenerate this file in the future when you upgrade to a
|
3
|
+
# newer version of cucumber-rails. Consider adding your own code to a new file
|
4
|
+
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
|
+
# files.
|
6
|
+
|
7
|
+
require 'cucumber/rails'
|
8
|
+
require 'capybara'
|
9
|
+
require 'capybara/rails'
|
10
|
+
|
11
|
+
# Capybara defaults to CSS3 selectors rather than XPath.
|
12
|
+
# If you'd prefer to use XPath, just uncomment this line and adjust any
|
13
|
+
# selectors in your step definitions to use the XPath syntax.
|
14
|
+
# Capybara.default_selector = :xpath
|
15
|
+
|
16
|
+
# By default, any exception happening in your Rails application will bubble up
|
17
|
+
# to Cucumber so that your scenario will fail. This is a different from how
|
18
|
+
# your application behaves in the production environment, where an error page will
|
19
|
+
# be rendered instead.
|
20
|
+
#
|
21
|
+
# Sometimes we want to override this default behaviour and allow Rails to rescue
|
22
|
+
# exceptions and display an error page (just like when the app is running in production).
|
23
|
+
# Typical scenarios where you want to do this is when you test your error pages.
|
24
|
+
# There are two ways to allow Rails to rescue exceptions:
|
25
|
+
#
|
26
|
+
# 1) Tag your scenario (or feature) with @allow-rescue
|
27
|
+
#
|
28
|
+
# 2) Set the value below to true. Beware that doing this globally is not
|
29
|
+
# recommended as it will mask a lot of errors for you!
|
30
|
+
#
|
31
|
+
ActionController::Base.allow_rescue = false
|
32
|
+
|
33
|
+
# Remove/comment out the lines below if your app doesn't have a database.
|
34
|
+
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
|
35
|
+
begin
|
36
|
+
DatabaseCleaner.strategy = :transaction
|
37
|
+
rescue NameError
|
38
|
+
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
|
39
|
+
end
|
40
|
+
|
41
|
+
# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
|
42
|
+
# See the DatabaseCleaner documentation for details. Example:
|
43
|
+
#
|
44
|
+
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
|
45
|
+
# # { :except => [:widgets] } may not do what you expect here
|
46
|
+
# # as Cucumber::Rails::Database.javascript_strategy overrides
|
47
|
+
# # this setting.
|
48
|
+
# DatabaseCleaner.strategy = :truncation
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
|
52
|
+
# DatabaseCleaner.strategy = :transaction
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
|
56
|
+
# Possible values are :truncation and :transaction
|
57
|
+
# The :transaction strategy is faster, but might give you threading problems.
|
58
|
+
# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
|
59
|
+
Cucumber::Rails::Database.javascript_strategy = :truncation
|
60
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module NavigationHelpers
|
2
|
+
def path_to(page_name)
|
3
|
+
case page_name
|
4
|
+
when /home page/
|
5
|
+
root_path
|
6
|
+
when /register/
|
7
|
+
'/register'
|
8
|
+
else
|
9
|
+
begin
|
10
|
+
page_name =~ /the (.*) page/
|
11
|
+
path_components = $1.split(/\s+/)
|
12
|
+
self.send(path_components.push('path').join('_').to_sym)
|
13
|
+
rescue Object => e
|
14
|
+
raise "can't find mapping from \"#{page_name}\" to a path. \n" + "Now, go and add a mapping in #{__FILE__}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
World(NavigationHelpers)
|
@@ -43,7 +43,7 @@ FORGE.features.assets.uploads = {
|
|
43
43
|
$('#queue').append($('<div />').attr('id', file.id).html($progressHTML));
|
44
44
|
$('#' + file.id +' .upload_status').html('Queued <strong>' + file.name + '</strong> for uploading.');
|
45
45
|
$.each($('input[name^=asset], select[name^=asset], textarea[name^=asset]'), function() {
|
46
|
-
$.swfupload.getInstance('#swfupload-control').addPostParam($this.attr('name'), $this.val());
|
46
|
+
$.swfupload.getInstance('#swfupload-control').addPostParam($(this).attr('name'), $(this).val());
|
47
47
|
});
|
48
48
|
$this.swfupload('startUpload');
|
49
49
|
$('#message').hide();
|
@@ -4,9 +4,9 @@ describe Forge::<%= class_name.pluralize %>Controller do
|
|
4
4
|
describe "As an admin" do
|
5
5
|
fixtures :users, :roles
|
6
6
|
before do
|
7
|
-
controller.stub
|
7
|
+
controller.stub(:current_user).and_return(users(:admin))
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
# NEW
|
11
11
|
describe "GET <%= plural_table_name %>/new" do
|
12
12
|
before do
|
@@ -14,16 +14,16 @@ describe Forge::<%= class_name.pluralize %>Controller do
|
|
14
14
|
<%= class_name %>.should_receive(:new).and_return(@<%= file_name %>)
|
15
15
|
get :new
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should assign @<%= file_name %>" do
|
19
19
|
assigns[:<%= file_name %>].should_not be_nil
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
it "should render the new template" do
|
23
23
|
response.should render_template('new')
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
# EDIT
|
28
28
|
describe "GET <%= plural_table_name %>/:id/edit" do
|
29
29
|
before do
|
@@ -31,146 +31,146 @@ describe Forge::<%= class_name.pluralize %>Controller do
|
|
31
31
|
<%= class_name %>.should_receive(:find).with("1").and_return(@<%= file_name %>)
|
32
32
|
get :edit, :id => 1
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
it "should assign @<%= file_name %>" do
|
36
36
|
assigns[:<%= file_name %>].should == @<%= file_name %>
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
it "should render the edit template" do
|
40
40
|
response.should render_template('edit')
|
41
41
|
end
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
|
45
45
|
# CREATE
|
46
46
|
describe "POST <%= plural_table_name %>/" do
|
47
47
|
def do_create
|
48
48
|
post :create, :<%= file_name %> => {}
|
49
49
|
end
|
50
|
-
|
51
|
-
describe "with valid attributes" do
|
50
|
+
|
51
|
+
describe "with valid attributes" do
|
52
52
|
before do
|
53
53
|
@<%= file_name %> = mock_model(<%= class_name %>, :save => true)
|
54
|
-
<%= class_name %>.stub
|
54
|
+
<%= class_name %>.stub(:new).and_return(@<%= file_name %>)
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
it "should assign @<%= file_name %>" do
|
58
58
|
do_create
|
59
59
|
assigns[:<%= file_name %>].should == @<%= file_name %>
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
it "should set the flash notice" do
|
63
63
|
do_create
|
64
64
|
flash[:notice].should_not be_nil
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
it "should redirect to the index" do
|
68
68
|
do_create
|
69
69
|
response.should redirect_to(forge_<%= plural_table_name %>_path)
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
it "should be valid" do
|
73
73
|
@<%= file_name %>.should_receive(:save).and_return(:true)
|
74
74
|
do_create
|
75
75
|
end
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
describe "with invalid attributes" do
|
79
79
|
before do
|
80
80
|
@<%= file_name %> = mock_model(<%= class_name %>, :save => false)
|
81
|
-
<%= class_name %>.stub
|
81
|
+
<%= class_name %>.stub(:new).and_return(@<%= file_name %>)
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
it "should assign @<%= file_name %>" do
|
85
85
|
do_create
|
86
86
|
assigns[:<%= file_name %>].should == @<%= file_name %>
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
it "should not set the flash notice" do
|
90
90
|
do_create
|
91
91
|
flash[:notice].should be_nil
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
it "should render the new template" do
|
95
95
|
do_create
|
96
96
|
response.should render_template('new')
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
it "should not save" do
|
100
100
|
@<%= file_name %>.should_receive(:save).and_return(:false)
|
101
101
|
do_create
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
105
|
-
|
105
|
+
|
106
106
|
# UPDATE
|
107
107
|
describe "PUT <%= plural_table_name %>/:id" do
|
108
108
|
def do_update
|
109
109
|
put :update, :id => "1", :<%= file_name %> => {}
|
110
|
-
end
|
111
|
-
|
110
|
+
end
|
111
|
+
|
112
112
|
describe "with valid params" do
|
113
113
|
before(:each) do
|
114
114
|
@<%= file_name %> = mock_model(<%= class_name %>, :update_attributes => true)
|
115
|
-
<%= class_name %>.stub
|
115
|
+
<%= class_name %>.stub(:find).with("1").and_return(@<%= file_name %>)
|
116
116
|
end
|
117
|
-
|
117
|
+
|
118
118
|
it "should find <%= file_name %> and return object" do
|
119
119
|
do_update
|
120
120
|
assigns[:<%= file_name %>].should == @<%= file_name %>
|
121
121
|
end
|
122
|
-
|
122
|
+
|
123
123
|
it "should update the <%= file_name %> object's attributes" do
|
124
124
|
@<%= file_name %>.should_receive(:update_attributes)
|
125
125
|
do_update
|
126
126
|
end
|
127
|
-
|
127
|
+
|
128
128
|
it "should redirect to the <%= file_name %> index page" do
|
129
129
|
do_update
|
130
130
|
response.should redirect_to(forge_<%= plural_table_name %>_path)
|
131
131
|
end
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
134
|
describe "with invalid params" do
|
135
135
|
before(:each) do
|
136
136
|
@<%= file_name %> = mock_model(<%= class_name %>, :update_attributes => false)
|
137
|
-
<%= class_name %>.stub
|
137
|
+
<%= class_name %>.stub(:find).with("1").and_return(@<%= file_name %>)
|
138
138
|
end
|
139
|
-
|
139
|
+
|
140
140
|
it "should find <%= file_name %> and return object" do
|
141
141
|
do_update
|
142
142
|
assigns[:<%= file_name %>].should == @<%= file_name %>
|
143
143
|
end
|
144
|
-
|
144
|
+
|
145
145
|
it "should update the <%= file_name %> object's attributes" do
|
146
146
|
@<%= file_name %>.should_receive(:update_attributes)
|
147
147
|
do_update
|
148
148
|
end
|
149
|
-
|
149
|
+
|
150
150
|
it "should render the edit form" do
|
151
151
|
do_update
|
152
152
|
response.should render_template('edit')
|
153
153
|
end
|
154
|
-
|
154
|
+
|
155
155
|
it "should not have a flash notice" do
|
156
156
|
do_update
|
157
157
|
flash[:notice].should be_blank
|
158
158
|
end
|
159
159
|
end
|
160
|
-
|
160
|
+
|
161
161
|
end
|
162
|
-
|
162
|
+
|
163
163
|
# DESTROY
|
164
164
|
describe "DELETE /<%= plural_table_name %>/:id" do
|
165
165
|
it "should delete" do
|
166
166
|
@<%= file_name %> = mock_model(<%= class_name %>)
|
167
|
-
<%= class_name %>.stub
|
167
|
+
<%= class_name %>.stub(:find).and_return(@<%= file_name %>)
|
168
168
|
@<%= file_name %>.should_receive(:destroy)
|
169
169
|
delete :destroy, :id => 1
|
170
170
|
end
|
171
171
|
end
|
172
|
-
<% unless attributes.select{|a| a.name == "list_order" }.empty? -%>
|
173
|
-
|
172
|
+
<% unless attributes.select{|a| a.name == "list_order" }.empty? -%>
|
173
|
+
|
174
174
|
# REORDER
|
175
175
|
describe "POST /<%= plural_table_name %>/reorder" do
|
176
176
|
it "should call reorder" do
|
@@ -178,35 +178,35 @@ describe Forge::<%= class_name.pluralize %>Controller do
|
|
178
178
|
post :reorder, :<%= file_name %>_list => ["1","2","3"]
|
179
179
|
end
|
180
180
|
end
|
181
|
-
<% end -%>
|
181
|
+
<% end -%>
|
182
182
|
end
|
183
|
-
|
184
|
-
|
183
|
+
|
184
|
+
|
185
185
|
describe "As someone who's not logged in" do
|
186
186
|
before do
|
187
|
-
controller.stub
|
187
|
+
controller.stub(:current_user).and_return(nil)
|
188
188
|
end
|
189
|
-
|
189
|
+
|
190
190
|
it "should not let you get the new action" do
|
191
191
|
get :new
|
192
192
|
response.should redirect_to('/login')
|
193
193
|
end
|
194
|
-
|
194
|
+
|
195
195
|
it "should not let you get the edit action" do
|
196
196
|
get :edit, :id => 1
|
197
197
|
response.should redirect_to('/login')
|
198
198
|
end
|
199
|
-
|
199
|
+
|
200
200
|
it "should not let you get the create action" do
|
201
201
|
post :create
|
202
202
|
response.should redirect_to('/login')
|
203
203
|
end
|
204
|
-
|
204
|
+
|
205
205
|
it "should not let you get the update action" do
|
206
206
|
put :update, :id => 1
|
207
207
|
response.should redirect_to('/login')
|
208
208
|
end
|
209
|
-
|
209
|
+
|
210
210
|
it "should not let you get the destroy action" do
|
211
211
|
delete :destroy, :id => 1
|
212
212
|
response.should redirect_to('/login')
|
@@ -4,9 +4,9 @@ describe Forge::<%= class_name.pluralize %>Controller do
|
|
4
4
|
describe "As an admin" do
|
5
5
|
fixtures :users, :roles
|
6
6
|
before do
|
7
|
-
controller.stub
|
7
|
+
controller.stub(:current_user).and_return(users(:admin))
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
# EDIT
|
11
11
|
describe "GET <%= plural_table_name %>/:id/edit" do
|
12
12
|
before do
|
@@ -14,145 +14,145 @@ describe Forge::<%= class_name.pluralize %>Controller do
|
|
14
14
|
<%= class_name %>.should_receive(:find).with("1").and_return(@<%= file_name %>)
|
15
15
|
get :edit, :id => 1
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should assign @<%= file_name %>" do
|
19
19
|
assigns[:<%= file_name %>].should == @<%= file_name %>
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
it "should render the edit template" do
|
23
23
|
response.should render_template('edit')
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
|
28
28
|
# CREATE
|
29
29
|
describe "POST <%= plural_table_name %>/" do
|
30
30
|
def do_create
|
31
31
|
post :create, :<%= file_name %> => {}
|
32
32
|
end
|
33
|
-
|
34
|
-
describe "with valid attributes" do
|
33
|
+
|
34
|
+
describe "with valid attributes" do
|
35
35
|
before do
|
36
36
|
@<%= file_name %> = mock_model(<%= class_name %>, :save => true)
|
37
|
-
<%= class_name %>.stub
|
37
|
+
<%= class_name %>.stub(:new).and_return(@<%= file_name %>)
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
it "should assign @<%= file_name %>" do
|
41
41
|
do_create
|
42
42
|
assigns[:<%= file_name %>].should == @<%= file_name %>
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
it "should set the flash notice" do
|
46
46
|
do_create
|
47
47
|
flash[:notice].should_not be_nil
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
it "should redirect to the index" do
|
51
51
|
do_create
|
52
52
|
response.should redirect_to(forge_<%= plural_table_name %>_path)
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
it "should be valid" do
|
56
56
|
@<%= file_name %>.should_receive(:save).and_return(:true)
|
57
57
|
do_create
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
describe "with invalid attributes" do
|
62
62
|
before do
|
63
63
|
@<%= file_name %> = mock_model(<%= class_name %>, :save => false)
|
64
|
-
<%= class_name %>.stub
|
64
|
+
<%= class_name %>.stub(:new).and_return(@<%= file_name %>)
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
it "should assign @<%= file_name %>" do
|
68
68
|
do_create
|
69
69
|
assigns[:<%= file_name %>].should == @<%= file_name %>
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
it "should not set the flash notice" do
|
73
73
|
do_create
|
74
74
|
flash[:notice].should be_nil
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
it "should render the index template" do
|
78
78
|
do_create
|
79
79
|
response.should render_template('index')
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
it "should not save" do
|
83
83
|
@<%= file_name %>.should_receive(:save).and_return(:false)
|
84
84
|
do_create
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
# UPDATE
|
90
90
|
describe "PUT <%= plural_table_name %>/:id" do
|
91
91
|
def do_update
|
92
92
|
put :update, :id => "1", :<%= file_name %> => {}
|
93
|
-
end
|
94
|
-
|
93
|
+
end
|
94
|
+
|
95
95
|
describe "with valid params" do
|
96
96
|
before(:each) do
|
97
97
|
@<%= file_name %> = mock_model(<%= class_name %>, :update_attributes => true)
|
98
|
-
<%= class_name %>.stub
|
98
|
+
<%= class_name %>.stub(:find).with("1").and_return(@<%= file_name %>)
|
99
99
|
end
|
100
|
-
|
100
|
+
|
101
101
|
it "should find <%= file_name %> and return object" do
|
102
102
|
do_update
|
103
103
|
assigns[:<%= file_name %>].should == @<%= file_name %>
|
104
104
|
end
|
105
|
-
|
105
|
+
|
106
106
|
it "should update the <%= file_name %> object's attributes" do
|
107
107
|
@<%= file_name %>.should_receive(:update_attributes)
|
108
108
|
do_update
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
it "should redirect to the <%= file_name %> index page" do
|
112
112
|
do_update
|
113
113
|
response.should redirect_to(forge_<%= plural_table_name %>_path)
|
114
114
|
end
|
115
115
|
end
|
116
|
-
|
116
|
+
|
117
117
|
describe "with invalid params" do
|
118
118
|
before(:each) do
|
119
119
|
@<%= file_name %> = mock_model(<%= class_name %>, :update_attributes => false)
|
120
|
-
<%= class_name %>.stub
|
120
|
+
<%= class_name %>.stub(:find).with("1").and_return(@<%= file_name %>)
|
121
121
|
end
|
122
|
-
|
122
|
+
|
123
123
|
it "should find <%= file_name %> and return object" do
|
124
124
|
do_update
|
125
125
|
assigns[:<%= file_name %>].should == @<%= file_name %>
|
126
126
|
end
|
127
|
-
|
127
|
+
|
128
128
|
it "should update the <%= file_name %> object's attributes" do
|
129
129
|
@<%= file_name %>.should_receive(:update_attributes)
|
130
130
|
do_update
|
131
131
|
end
|
132
|
-
|
132
|
+
|
133
133
|
it "should render the edit form" do
|
134
134
|
do_update
|
135
135
|
response.should render_template('edit')
|
136
136
|
end
|
137
|
-
|
137
|
+
|
138
138
|
it "should not have a flash notice" do
|
139
139
|
do_update
|
140
140
|
flash[:notice].should be_blank
|
141
141
|
end
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
end
|
145
|
-
|
145
|
+
|
146
146
|
# DESTROY
|
147
147
|
describe "DELETE /<%= plural_table_name %>/:id" do
|
148
148
|
it "should delete" do
|
149
149
|
@<%= file_name %> = mock_model(<%= class_name %>)
|
150
|
-
<%= class_name %>.stub
|
150
|
+
<%= class_name %>.stub(:find).and_return(@<%= file_name %>)
|
151
151
|
@<%= file_name %>.should_receive(:destroy)
|
152
152
|
delete :destroy, :id => 1
|
153
153
|
end
|
154
154
|
end
|
155
|
-
<% unless attributes.select{|a| a.name == "list_order" }.empty? -%>
|
155
|
+
<% unless attributes.select{|a| a.name == "list_order" }.empty? -%>
|
156
156
|
|
157
157
|
# REORDER
|
158
158
|
describe "POST /<%= plural_table_name %>/reorder" do
|
@@ -163,28 +163,28 @@ describe Forge::<%= class_name.pluralize %>Controller do
|
|
163
163
|
end
|
164
164
|
<% end -%>
|
165
165
|
end
|
166
|
-
|
167
|
-
|
166
|
+
|
167
|
+
|
168
168
|
describe "As someone who's not logged in" do
|
169
169
|
before do
|
170
|
-
controller.stub
|
170
|
+
controller.stub(:current_user).and_return(nil)
|
171
171
|
end
|
172
|
-
|
172
|
+
|
173
173
|
it "should not let you get the edit action" do
|
174
174
|
get :edit, :id => 1
|
175
175
|
response.should redirect_to('/login')
|
176
176
|
end
|
177
|
-
|
177
|
+
|
178
178
|
it "should not let you get the create action" do
|
179
179
|
post :create
|
180
180
|
response.should redirect_to('/login')
|
181
181
|
end
|
182
|
-
|
182
|
+
|
183
183
|
it "should not let you get the update action" do
|
184
184
|
put :update, :id => 1
|
185
185
|
response.should redirect_to('/login')
|
186
186
|
end
|
187
|
-
|
187
|
+
|
188
188
|
it "should not let you get the destroy action" do
|
189
189
|
delete :destroy, :id => 1
|
190
190
|
response.should redirect_to('/login')
|