fetty-generators 2.0.3 → 2.0.4
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.
- data/lib/generators/fetty.rb +40 -17
- data/lib/generators/fetty/authentication/USAGE +6 -1
- data/lib/generators/fetty/authentication/authentication_generator.rb +16 -10
- data/lib/generators/fetty/authentication/templates/controllers/sessions_controller.rb +3 -0
- data/lib/generators/fetty/authentication/templates/controllers/users_controller.rb +5 -1
- data/lib/generators/fetty/authentication/templates/lib/users_authentication.rb +1 -1
- data/lib/generators/fetty/authentication/templates/spec/controllers/sessions_controller_spec.rb +12 -2
- data/lib/generators/fetty/authentication/templates/spec/controllers/users_controller_spec.rb +13 -2
- data/lib/generators/fetty/messages/USAGE +5 -0
- data/lib/generators/fetty/messages/messages_generator.rb +21 -13
- data/lib/generators/fetty/messages/templates/spec/controllers/messages_controller_spec.rb +5 -0
- data/lib/generators/fetty/messages/templates/spec/support/message_factories.rb +3 -3
- data/lib/generators/fetty/scaffold/USAGE +13 -0
- data/lib/generators/fetty/scaffold/scaffold_generator.rb +6 -16
- data/lib/generators/fetty/scaffold/templates/{test/rspec → spec}/controller.rb +45 -14
- data/lib/generators/fetty/scaffold/templates/{test/rspec → spec}/factories.rb +0 -0
- data/lib/generators/fetty/scaffold/templates/{test/rspec → spec}/helper.rb +0 -0
- data/lib/generators/fetty/scaffold/templates/{test/rspec → spec}/model.rb +0 -0
- data/lib/generators/fetty/scaffold/templates/{test/rspec → spec}/request.rb +0 -0
- data/lib/generators/fetty/scaffold/templates/{test/rspec → spec}/routing.rb +0 -0
- data/lib/generators/fetty/scaffold/templates/views/_form.html.erb +4 -0
- data/lib/generators/fetty/setup/USAGE +12 -1
- data/lib/generators/fetty/setup/setup_generator.rb +56 -39
- data/lib/generators/fetty/setup/templates/Guardfile +45 -0
- data/lib/generators/fetty/setup/templates/env.rb +83 -44
- data/lib/generators/fetty/setup/templates/spec_helper.rb +77 -39
- data/lib/generators/fetty/views/USAGE +10 -0
- data/lib/generators/fetty/views/templates/application.css +5 -0
- data/lib/generators/fetty/views/templates/application.html.erb +19 -15
- data/lib/generators/fetty/views/templates/application.js +0 -2
- data/lib/generators/fetty/views/views_generator.rb +6 -6
- metadata +10 -14
- data/lib/generators/fetty/authentication/templates/views/layouts/application.html.erb +0 -33
- data/lib/generators/fetty/scaffold/templates/test/test_unit/controller.rb +0 -62
- data/lib/generators/fetty/scaffold/templates/test/test_unit/fixtures.yml +0 -11
- data/lib/generators/fetty/scaffold/templates/test/test_unit/helper.rb +0 -4
- data/lib/generators/fetty/scaffold/templates/test/test_unit/model.rb +0 -7
data/lib/generators/fetty.rb
CHANGED
@@ -39,17 +39,6 @@ protected
|
|
39
39
|
return false
|
40
40
|
end
|
41
41
|
|
42
|
-
def destroy(path)
|
43
|
-
begin
|
44
|
-
if file_exists?(path)
|
45
|
-
print_notes("Destroying #{path}")
|
46
|
-
FileUtils.rm_r(destination_path(path), :force => true)
|
47
|
-
end
|
48
|
-
rescue Exception => e
|
49
|
-
raise e
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
42
|
def extract(filepath,destinationpath,foldername)
|
54
43
|
begin
|
55
44
|
print_notes("Extracting #{filepath}")
|
@@ -152,12 +141,6 @@ protected
|
|
152
141
|
raise e
|
153
142
|
end
|
154
143
|
|
155
|
-
def using_test_unit?
|
156
|
-
folder_exists?("tests")
|
157
|
-
rescue Exception => e
|
158
|
-
raise e
|
159
|
-
end
|
160
|
-
|
161
144
|
def using_rspec?
|
162
145
|
gemfile_included?("rspec") && folder_exists?("spec")
|
163
146
|
rescue Exception => e
|
@@ -182,6 +165,46 @@ protected
|
|
182
165
|
raise e
|
183
166
|
end
|
184
167
|
|
168
|
+
def rails_3_1?
|
169
|
+
Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR >= 1
|
170
|
+
end
|
171
|
+
|
172
|
+
def copy_asset(source, *args, &block)
|
173
|
+
if rails_3_1?
|
174
|
+
if args.first =~ /^public/
|
175
|
+
args.first.gsub!(/^public/,"app/assets")
|
176
|
+
end
|
177
|
+
if args.first.include?("javascripts/application.js") or args.first.include?("stylesheets/application.css")
|
178
|
+
last_line = IO.readlines(args.first).last
|
179
|
+
content = IO.read(File.expand_path(find_in_source_paths(source.to_s)))
|
180
|
+
content.gsub!(/images/,"assets")
|
181
|
+
inject_into_file args.first, :after => last_line do
|
182
|
+
content
|
183
|
+
end
|
184
|
+
return
|
185
|
+
end
|
186
|
+
end
|
187
|
+
copy_file(source, *args, &block)
|
188
|
+
end
|
189
|
+
|
190
|
+
def remove_asset(path, config={})
|
191
|
+
if rails_3_1?
|
192
|
+
if path =~ /^public/
|
193
|
+
path.gsub!(/^public/,"app/assets")
|
194
|
+
end
|
195
|
+
end
|
196
|
+
remove_asset(path, config)
|
197
|
+
end
|
198
|
+
|
199
|
+
def gem_group(*names, &block)
|
200
|
+
name = names.map(&:inspect).join(", ")
|
201
|
+
log :gemfile, "group #{name}"
|
202
|
+
append_file "Gemfile", "\n## MARK THIS IS GROUP ##\n", :force => true, :verbose => false
|
203
|
+
yield
|
204
|
+
gsub_file 'Gemfile', /## MARK THIS IS GROUP ##/m, "group #{name} do", :verbose => false
|
205
|
+
append_file "Gemfile", "end\n", :force => true, :verbose => false
|
206
|
+
end
|
207
|
+
|
185
208
|
end
|
186
209
|
end
|
187
210
|
end
|
@@ -1,4 +1,9 @@
|
|
1
1
|
Description:
|
2
|
-
The fetty:authentication generator creates a basic
|
2
|
+
The fetty:authentication generator creates a basic authentication system
|
3
3
|
between user in your app.
|
4
4
|
|
5
|
+
To Install:
|
6
|
+
rails g fetty:authentication
|
7
|
+
|
8
|
+
To Remove:
|
9
|
+
rails g fetty:authentication --destroy
|
@@ -24,8 +24,7 @@ module Fetty
|
|
24
24
|
edit_application_controller
|
25
25
|
must_load_lib_directory
|
26
26
|
add_routes
|
27
|
-
|
28
|
-
generate_test_unit if using_test_unit?
|
27
|
+
insert_links_on_layout
|
29
28
|
generate_specs if using_rspec?
|
30
29
|
print_notes "Make sure you have defined root_url in your 'config/routes.rb.'"
|
31
30
|
else
|
@@ -38,6 +37,21 @@ module Fetty
|
|
38
37
|
|
39
38
|
private
|
40
39
|
|
40
|
+
def insert_links_on_layout
|
41
|
+
inject_into_file "app/views/layouts/application.html.erb", :before => "<%= content_tag :h1, yield(:title) if show_title? %>" do
|
42
|
+
"\n\t <div id='loginbox'>" +
|
43
|
+
"\n\t <% if user_signed_in? %>" +
|
44
|
+
"\n\t Signed in as <%= link_to current_user.username, user_path(current_user) %> Not You?" +
|
45
|
+
"\n\t <%= link_to 'Sign out', session_path, :method => :delete %>" +
|
46
|
+
"\n\t <% else %>" +
|
47
|
+
"\n\t <%= link_to 'Sign up', new_user_path %> or <%= link_to 'Sign in', new_session_path %>" +
|
48
|
+
"\n\t <% end %>" +
|
49
|
+
"\n\t </div>\n"
|
50
|
+
end
|
51
|
+
rescue Exception => e
|
52
|
+
raise e
|
53
|
+
end
|
54
|
+
|
41
55
|
def generate_users
|
42
56
|
copy_file "controllers/users_controller.rb", "app/controllers/users_controller.rb"
|
43
57
|
copy_file "helpers/users_helper.rb", "app/helpers/users_helper.rb"
|
@@ -105,10 +119,6 @@ private
|
|
105
119
|
end
|
106
120
|
end
|
107
121
|
|
108
|
-
def generate_test_unit
|
109
|
-
|
110
|
-
end
|
111
|
-
|
112
122
|
def generate_specs
|
113
123
|
copy_file "spec/controllers/users_controller_spec.rb", "spec/controllers/users_controller_spec.rb"
|
114
124
|
copy_file "spec/models/user_spec.rb", "spec/models/user_spec.rb"
|
@@ -144,10 +154,6 @@ private
|
|
144
154
|
gsub_file 'app/controllers/application_controller.rb', /include SessionsAuthentication.*:authenticate_user!/m, ''
|
145
155
|
gsub_file 'config/routes.rb', /resources :users.*(\s*end){3}/m, ''
|
146
156
|
|
147
|
-
if using_test_unit?
|
148
|
-
|
149
|
-
end
|
150
|
-
|
151
157
|
if using_rspec?
|
152
158
|
remove_file 'spec/controllers/users_controller_spec.rb'
|
153
159
|
remove_file 'spec/models/user_spec.rb'
|
@@ -16,7 +16,11 @@ class UsersController < ApplicationController
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def new
|
19
|
-
|
19
|
+
unless user_signed_in?
|
20
|
+
@user = User.new
|
21
|
+
else
|
22
|
+
redirect_to redirect_to_target_or_default_url, :alert => "You already sign-up! Please log-out first."
|
23
|
+
end
|
20
24
|
end
|
21
25
|
|
22
26
|
def create
|
data/lib/generators/fetty/authentication/templates/spec/controllers/sessions_controller_spec.rb
CHANGED
@@ -2,16 +2,26 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SessionsController do
|
4
4
|
|
5
|
+
def stub_authenticate_user
|
6
|
+
controller.stub(:authenticate_user!).and_return(true)
|
7
|
+
end
|
8
|
+
|
5
9
|
describe "GET new" do
|
6
10
|
it "should render sign-in page" do
|
7
11
|
get :new
|
8
12
|
response.should be_success
|
9
13
|
end
|
14
|
+
|
15
|
+
it "should not render sign-in page if already sign-in" do
|
16
|
+
controller.stub(:user_signed_in?).and_return(true)
|
17
|
+
get :new
|
18
|
+
flash[:alert].should_not be_nil
|
19
|
+
end
|
10
20
|
end
|
11
21
|
|
12
22
|
describe "POST create" do
|
13
23
|
describe "with valid params" do
|
14
|
-
it "should authenticate user" do
|
24
|
+
it "should authenticate user and redirect to root_path" do
|
15
25
|
user = Factory(:user, :email => "some@email.com", :password => "secret", :password_confirmation => "secret")
|
16
26
|
User.stub(:authenticate!).with("some@email.com", "secret").and_return(user)
|
17
27
|
post :create, :login => "some@email.com", :password => "secret"
|
@@ -49,7 +59,7 @@ describe SessionsController do
|
|
49
59
|
end
|
50
60
|
|
51
61
|
describe "DELETE destroy" do
|
52
|
-
it "should destroy session or cookies" do
|
62
|
+
it "should destroy session or cookies and redirect to root_path" do
|
53
63
|
stub_authenticate_user
|
54
64
|
delete :destroy
|
55
65
|
assigns(:current_user).should be_nil
|
data/lib/generators/fetty/authentication/templates/spec/controllers/users_controller_spec.rb
CHANGED
@@ -2,6 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe UsersController do
|
4
4
|
|
5
|
+
def stub_authenticate_user
|
6
|
+
controller.stub(:authenticate_user!).and_return(true)
|
7
|
+
end
|
8
|
+
|
5
9
|
def test_assigns_user_object(action)
|
6
10
|
user = Factory(:user)
|
7
11
|
User.stub(:find).with(user.id.to_s).and_return(user)
|
@@ -26,9 +30,16 @@ describe UsersController do
|
|
26
30
|
end
|
27
31
|
|
28
32
|
describe "GET new" do
|
29
|
-
it "assigns a new user as @user" do
|
33
|
+
it "should render sign-up page and assigns a new user as @user" do
|
30
34
|
get :new
|
31
35
|
assigns(:user).should be_a_new(User)
|
36
|
+
response.should be_success
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should not render sign-up page if user already sign-in" do
|
40
|
+
controller.stub(:user_signed_in?).and_return(true)
|
41
|
+
get :new
|
42
|
+
flash[:alert].should_not be_nil
|
32
43
|
end
|
33
44
|
end
|
34
45
|
|
@@ -126,7 +137,7 @@ describe UsersController do
|
|
126
137
|
end
|
127
138
|
|
128
139
|
describe "with valid params" do
|
129
|
-
it "should activate user with given id and token" do
|
140
|
+
it "should activate user with given id and token and redirect to root_path" do
|
130
141
|
User.stub(:activate!).with(@user.id.to_s, @user.token).and_return(@user)
|
131
142
|
get :activate, :id => @user.id.to_s, :token => @user.token
|
132
143
|
assigns(:user).should be_a(User)
|
@@ -28,7 +28,7 @@ module Fetty
|
|
28
28
|
copy_assets
|
29
29
|
must_load_lib_directory
|
30
30
|
add_routes
|
31
|
-
|
31
|
+
insert_links_on_layout
|
32
32
|
generate_specs if using_rspec?
|
33
33
|
else
|
34
34
|
raise "Sorry, fetty:messages only works with ActiveRecord !!"
|
@@ -43,6 +43,18 @@ module Fetty
|
|
43
43
|
|
44
44
|
private
|
45
45
|
|
46
|
+
def insert_links_on_layout
|
47
|
+
inject_into_file "app/views/layouts/application.html.erb", :before => "<%= content_tag :h1, yield(:title) if show_title? %>" do
|
48
|
+
"\n\t <div id='messagebox'>" +
|
49
|
+
"\n\t <% if user_signed_in? %>" +
|
50
|
+
"\n\t <%= link_to \"inbox(\#{current_user.inbox(:opened => false).count})\", messages_path(:inbox), :id => 'inbox-link' %>" +
|
51
|
+
"\n\t <% end %>" +
|
52
|
+
"\n\t </div>\n"
|
53
|
+
end
|
54
|
+
rescue Exception => e
|
55
|
+
raise e
|
56
|
+
end
|
57
|
+
|
46
58
|
def copy_models_and_migrations
|
47
59
|
copy_file "models/#{@orm}/message.rb", "app/models/message.rb"
|
48
60
|
migration_template "models/active_record/create_messages.rb", "db/migrate/create_messages.rb" unless using_mongoid?
|
@@ -70,10 +82,10 @@ private
|
|
70
82
|
end
|
71
83
|
|
72
84
|
def copy_assets
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
85
|
+
copy_asset 'assets/stylesheets/messages.css', 'public/stylesheets/messages.css'
|
86
|
+
copy_asset 'assets/stylesheets/token-input-facebook.css', 'public/stylesheets/token-input-facebook.css'
|
87
|
+
copy_asset 'assets/javascripts/messages.js', 'public/javascripts/messages.js'
|
88
|
+
copy_asset 'assets/javascripts/jquery.tokeninput.js', 'public/javascripts/jquery.tokeninput.js'
|
77
89
|
end
|
78
90
|
|
79
91
|
def add_routes
|
@@ -90,10 +102,6 @@ private
|
|
90
102
|
end
|
91
103
|
end
|
92
104
|
|
93
|
-
def generate_test_unit
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
105
|
def generate_specs
|
98
106
|
copy_file "spec/controllers/messages_controller_spec.rb", "spec/controllers/messages_controller_spec.rb"
|
99
107
|
copy_file "spec/models/message_spec.rb", "spec/models/message_spec.rb"
|
@@ -111,10 +119,10 @@ private
|
|
111
119
|
remove_file "app/controllers/messages_controller.rb"
|
112
120
|
remove_file "app/helpers/messages_helper.rb"
|
113
121
|
remove_dir "app/views/messages"
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
122
|
+
remove_asset 'public/stylesheets/messages.css'
|
123
|
+
remove_asset 'public/stylesheets/token-input-facebook.css'
|
124
|
+
remove_asset 'public/javascripts/messages.js'
|
125
|
+
remove_asset 'public/javascripts/jquery.tokeninput.js'
|
118
126
|
gsub_file 'config/routes.rb', /resources :messages.*:constraints => { :messagebox => \/inbox|outbox|trash\/ }(\s*end){2}/m, ''
|
119
127
|
|
120
128
|
if using_rspec?
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Factory.define :message do |f|
|
2
|
-
f.
|
3
|
-
f.
|
4
|
-
f.
|
2
|
+
f.user_id 1
|
3
|
+
f.sender_id 1
|
4
|
+
f.recipient_id 2
|
5
5
|
f.subject_id 1
|
6
6
|
f.subject "testing"
|
7
7
|
f.content "This is only test !!"
|
@@ -1,3 +1,16 @@
|
|
1
1
|
Description:
|
2
2
|
The fetty:scaffold generator creates a basic scaffolding
|
3
3
|
using many useful gems.
|
4
|
+
|
5
|
+
Additional field type:
|
6
|
+
- editor
|
7
|
+
- image
|
8
|
+
- file
|
9
|
+
|
10
|
+
Example:
|
11
|
+
|
12
|
+
rails g fetty:scaffold post title:string content:text published:boolean
|
13
|
+
|
14
|
+
or with additional field type:
|
15
|
+
|
16
|
+
rails g fetty:scaffold post title:string content:editor photo:image attachment:file
|
@@ -45,7 +45,6 @@ module Fetty
|
|
45
45
|
end
|
46
46
|
|
47
47
|
if options.test?
|
48
|
-
generate_test_unit if using_test_unit?
|
49
48
|
generate_specs if using_rspec?
|
50
49
|
end
|
51
50
|
else
|
@@ -109,22 +108,13 @@ private
|
|
109
108
|
end
|
110
109
|
end
|
111
110
|
|
112
|
-
def generate_test_unit
|
113
|
-
template "test/test_unit/controller.rb", "test/functional/#{plural_name}_controller_test.rb"
|
114
|
-
template "test/test_unit/fixtures.yml", "test/fixtures/#{plural_name}.yml"
|
115
|
-
template "test/test_unit/model.rb", "test/unit/#{singular_name}_test.rb"
|
116
|
-
template "test/test_unit/helper.rb", "test/unit/helpers/#{plural_name}_helper_test.rb"
|
117
|
-
rescue Exception => e
|
118
|
-
raise e
|
119
|
-
end
|
120
|
-
|
121
111
|
def generate_specs
|
122
|
-
template "
|
123
|
-
template "
|
124
|
-
template "
|
125
|
-
template "
|
126
|
-
template "
|
127
|
-
template "
|
112
|
+
template "spec/controller.rb", "spec/controllers/#{plural_name}_controller_spec.rb"
|
113
|
+
template "spec/model.rb", "spec/models/#{singular_name}_spec.rb"
|
114
|
+
template "spec/helper.rb", "spec/helpers/#{plural_name}_helper_test.rb"
|
115
|
+
template "spec/request.rb", "spec/requests/#{singular_name}_spec.rb.rb"
|
116
|
+
template "spec/routing.rb", "spec/routing/#{plural_name}_routing_spec.rb"
|
117
|
+
template "spec/factories.rb", "spec/support/#{singular_name}_factories.rb"
|
128
118
|
rescue Exception => e
|
129
119
|
raise e
|
130
120
|
end
|
@@ -1,39 +1,57 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe <%= controller_name %> do
|
4
|
-
|
4
|
+
|
5
|
+
<%- if using_fetty_authentication? -%>
|
6
|
+
def stub_authenticate_user
|
7
|
+
controller.stub(:authenticate_user!).and_return(true)
|
8
|
+
end
|
9
|
+
<%- end -%>
|
10
|
+
|
11
|
+
<%- if action? :index -%>
|
5
12
|
describe "GET index" do
|
6
13
|
it "should render index template" do
|
14
|
+
<%- if using_fetty_authentication? -%>
|
7
15
|
stub_authenticate_user
|
16
|
+
<%- end -%>
|
8
17
|
get :index
|
9
18
|
response.should render_template(:index)
|
10
19
|
end
|
11
20
|
end
|
12
|
-
|
13
|
-
|
21
|
+
<%- end -%>
|
22
|
+
|
23
|
+
<%- if action? :show -%>
|
14
24
|
describe "GET show" do
|
15
25
|
it "should render show template" do
|
26
|
+
<%- if using_fetty_authentication? -%>
|
16
27
|
stub_authenticate_user
|
28
|
+
<%- end -%>
|
17
29
|
<%= instance_name %> = Factory(<%= instance_name(':') %>)
|
18
30
|
get :show, :id => <%= instance_name %>.id.to_s
|
19
31
|
response.should render_template(:show)
|
20
32
|
end
|
21
33
|
end
|
22
|
-
|
23
|
-
|
34
|
+
<%- end -%>
|
35
|
+
|
36
|
+
<%- if action? :new -%>
|
24
37
|
describe "GET new" do
|
25
38
|
it "should render new template" do
|
39
|
+
<%- if using_fetty_authentication? -%>
|
26
40
|
stub_authenticate_user
|
41
|
+
<%- end -%>
|
27
42
|
get :new
|
28
43
|
response.should render_template(:new)
|
29
44
|
end
|
30
45
|
end
|
31
|
-
|
32
|
-
|
46
|
+
<%- end -%>
|
47
|
+
|
48
|
+
<%- if action? :create -%>
|
33
49
|
describe "POST create" do
|
34
50
|
describe "with valid params" do
|
35
51
|
it "should redirect to show template" do
|
52
|
+
<%- if using_fetty_authentication? -%>
|
36
53
|
stub_authenticate_user
|
54
|
+
<%- end -%>
|
37
55
|
<%= class_name %>.any_instance.stub(:valid?).and_return(true)
|
38
56
|
post :create, <%= instance_name(':') %> => Factory.attributes_for(<%= instance_name(':') %>)
|
39
57
|
response.should redirect_to(<%= generate_route_link(:action => :show, :suffix => 'path', :object => "assigns(#{instance_name(':')})") %>)
|
@@ -42,29 +60,37 @@ describe <%= controller_name %> do
|
|
42
60
|
|
43
61
|
describe "with invalid params" do
|
44
62
|
it "should re-render new template" do
|
63
|
+
<%- if using_fetty_authentication? -%>
|
45
64
|
stub_authenticate_user
|
65
|
+
<%- end -%>
|
46
66
|
<%= class_name %>.any_instance.stub(:valid?).and_return(false)
|
47
67
|
post :create, <%= instance_name(':') %> => nil
|
48
68
|
response.should render_template(:new)
|
49
69
|
end
|
50
70
|
end
|
51
71
|
end
|
52
|
-
|
53
|
-
|
72
|
+
<%- end -%>
|
73
|
+
|
74
|
+
<%- if action? :edit -%>
|
54
75
|
describe "GET edit" do
|
55
76
|
it "should render edit template" do
|
77
|
+
<%- if using_fetty_authentication? -%>
|
56
78
|
stub_authenticate_user
|
79
|
+
<%- end -%>
|
57
80
|
<%= instance_name %> = Factory(<%= instance_name(':') %>)
|
58
81
|
get :edit, :id => <%= instance_name %>.id.to_s
|
59
82
|
response.should render_template(:edit)
|
60
83
|
end
|
61
84
|
end
|
62
|
-
|
63
|
-
|
85
|
+
<%- end -%>
|
86
|
+
|
87
|
+
<%- if action? :update -%>
|
64
88
|
describe "PUT update" do
|
65
89
|
describe "with valid params" do
|
66
90
|
it "should redirect to show template" do
|
91
|
+
<%- if using_fetty_authentication? -%>
|
67
92
|
stub_authenticate_user
|
93
|
+
<%- end -%>
|
68
94
|
<%= instance_name %> = Factory(<%= instance_name(':') %>)
|
69
95
|
<%= class_name %>.stub(:find).with(<%= instance_name %>.id.to_s).and_return(<%= instance_name %>)
|
70
96
|
<%= class_name %>.any_instance.stub(:valid?).and_return(true)
|
@@ -75,7 +101,9 @@ describe <%= controller_name %> do
|
|
75
101
|
|
76
102
|
describe "with invalid params" do
|
77
103
|
it "should re-render edit template" do
|
104
|
+
<%- if using_fetty_authentication? -%>
|
78
105
|
stub_authenticate_user
|
106
|
+
<%- end -%>
|
79
107
|
<%= instance_name %> = Factory(<%= instance_name(':') %>)
|
80
108
|
<%= class_name %>.stub(:find).with(<%= instance_name %>.id.to_s).and_return(<%= instance_name %>)
|
81
109
|
<%= class_name %>.any_instance.stub(:valid?).and_return(false)
|
@@ -84,15 +112,18 @@ describe <%= controller_name %> do
|
|
84
112
|
end
|
85
113
|
end
|
86
114
|
end
|
87
|
-
|
88
|
-
|
115
|
+
<%- end -%>
|
116
|
+
|
117
|
+
<%- if action? :destroy -%>
|
89
118
|
describe "DELETE destroy" do
|
90
119
|
it "should redirect to index template" do
|
120
|
+
<%- if using_fetty_authentication? -%>
|
91
121
|
stub_authenticate_user
|
122
|
+
<%- end -%>
|
92
123
|
<%= instance_name %> = Factory(<%= instance_name(':') %>)
|
93
124
|
delete :destroy, :id => <%= instance_name %>.id.to_s
|
94
125
|
response.should redirect_to(<%= generate_route_link(:action => :index, :suffix => 'path') %>)
|
95
126
|
end
|
96
127
|
end
|
97
|
-
|
128
|
+
<%- end -%>
|
98
129
|
end
|