rotten-generators 0.9.0
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/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +10 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/cucumber.yml +1 -0
- data/features/rotten.feature +9 -0
- data/features/step_definitions/rotten_steps.rb +0 -0
- data/features/support/env.rb +4 -0
- data/generators.gemspec +126 -0
- data/lib/rotten_generators.rb +3 -0
- data/rails_generators/rotten_authentication/lib/insert_commands.rb +74 -0
- data/rails_generators/rotten_authentication/rotten_authentication_generator.rb +102 -0
- data/rails_generators/rotten_authentication/templates/authentication.rb +37 -0
- data/rails_generators/rotten_authentication/templates/fixtures.yml +12 -0
- data/rails_generators/rotten_authentication/templates/migration.rb +15 -0
- data/rails_generators/rotten_authentication/templates/sessions_controller.rb +22 -0
- data/rails_generators/rotten_authentication/templates/sessions_helper.rb +2 -0
- data/rails_generators/rotten_authentication/templates/tests/rspec/sessions_controller.rb +25 -0
- data/rails_generators/rotten_authentication/templates/tests/rspec/user.rb +81 -0
- data/rails_generators/rotten_authentication/templates/tests/rspec/users_controller.rb +24 -0
- data/rails_generators/rotten_authentication/templates/user.rb +38 -0
- data/rails_generators/rotten_authentication/templates/users_controller.rb +16 -0
- data/rails_generators/rotten_authentication/templates/users_helper.rb +2 -0
- data/rails_generators/rotten_authentication/templates/views/haml/login.html.haml +15 -0
- data/rails_generators/rotten_authentication/templates/views/haml/signup.html.haml +24 -0
- data/rails_generators/rotten_controller/rotten_controller_generator.rb +52 -0
- data/rails_generators/rotten_controller/templates/controller.rb +38 -0
- data/rails_generators/rotten_controller/templates/controller_spec.rb +25 -0
- data/rails_generators/rotten_controller/templates/helper.rb +2 -0
- data/rails_generators/rotten_controller/templates/helper_spec.rb +11 -0
- data/rails_generators/rotten_controller/templates/view.html.haml +2 -0
- data/rails_generators/rotten_controller/templates/view_spec.rb +12 -0
- data/rails_generators/rotten_layout/USAGE +1 -0
- data/rails_generators/rotten_layout/rotten_layout_generator.rb +63 -0
- data/rails_generators/rotten_layout/templates/helper.rb +30 -0
- data/rails_generators/rotten_layout/templates/js/jquery-1.3.2.min.js +19 -0
- data/rails_generators/rotten_layout/templates/js/jquery-ui-1.7.2.min.js +298 -0
- data/rails_generators/rotten_layout/templates/layout.html.haml +45 -0
- data/rails_generators/rotten_layout/templates/one_column.html.haml +11 -0
- data/rails_generators/rotten_layout/templates/sass/colour.sass +1 -0
- data/rails_generators/rotten_layout/templates/sass/form.sass +1 -0
- data/rails_generators/rotten_layout/templates/sass/handheld.sass +1 -0
- data/rails_generators/rotten_layout/templates/sass/ie.sass +1 -0
- data/rails_generators/rotten_layout/templates/sass/layout.sass +1 -0
- data/rails_generators/rotten_layout/templates/sass/print.sass +1 -0
- data/rails_generators/rotten_layout/templates/sass/reset.sass +137 -0
- data/rails_generators/rotten_layout/templates/sass/screen.sass +5 -0
- data/rails_generators/rotten_layout/templates/sass/type.sass +1 -0
- data/rails_generators/rotten_layout/templates/shared_analytics.html.haml +10 -0
- data/rails_generators/rotten_layout/templates/shared_flash_messages.html.haml +12 -0
- data/rails_generators/rotten_layout/templates/shared_footer.html.haml +15 -0
- data/rails_generators/rotten_layout/templates/shared_header.html.haml +5 -0
- data/rails_generators/rotten_layout/templates/shared_navigation.html.haml +3 -0
- data/rails_generators/rotten_layout/templates/shared_sidebar.html.haml +13 -0
- data/rails_generators/rotten_layout/templates/two_column_left.html.haml +15 -0
- data/rails_generators/rotten_layout/templates/two_column_right.html.haml +14 -0
- data/rails_generators/rotten_scaffold/USAGE +48 -0
- data/rails_generators/rotten_scaffold/rotten_scaffold_generator.rb +204 -0
- data/rails_generators/rotten_scaffold/templates/actions/create.rb +9 -0
- data/rails_generators/rotten_scaffold/templates/actions/destroy.rb +6 -0
- data/rails_generators/rotten_scaffold/templates/actions/edit.rb +3 -0
- data/rails_generators/rotten_scaffold/templates/actions/index.rb +3 -0
- data/rails_generators/rotten_scaffold/templates/actions/new.rb +3 -0
- data/rails_generators/rotten_scaffold/templates/actions/show.rb +3 -0
- data/rails_generators/rotten_scaffold/templates/actions/update.rb +9 -0
- data/rails_generators/rotten_scaffold/templates/controller.rb +3 -0
- data/rails_generators/rotten_scaffold/templates/fixtures.yml +9 -0
- data/rails_generators/rotten_scaffold/templates/helper.rb +2 -0
- data/rails_generators/rotten_scaffold/templates/migration.rb +16 -0
- data/rails_generators/rotten_scaffold/templates/model.rb +2 -0
- data/rails_generators/rotten_scaffold/templates/tests/rspec/actions/create.rb +11 -0
- data/rails_generators/rotten_scaffold/templates/tests/rspec/actions/destroy.rb +6 -0
- data/rails_generators/rotten_scaffold/templates/tests/rspec/actions/edit.rb +4 -0
- data/rails_generators/rotten_scaffold/templates/tests/rspec/actions/index.rb +4 -0
- data/rails_generators/rotten_scaffold/templates/tests/rspec/actions/new.rb +4 -0
- data/rails_generators/rotten_scaffold/templates/tests/rspec/actions/show.rb +4 -0
- data/rails_generators/rotten_scaffold/templates/tests/rspec/actions/update.rb +11 -0
- data/rails_generators/rotten_scaffold/templates/tests/rspec/controller.rb +8 -0
- data/rails_generators/rotten_scaffold/templates/tests/rspec/model.rb +7 -0
- data/rails_generators/rotten_scaffold/templates/views/haml/_form.html.haml +14 -0
- data/rails_generators/rotten_scaffold/templates/views/haml/edit.html.haml +14 -0
- data/rails_generators/rotten_scaffold/templates/views/haml/index.html.haml +25 -0
- data/rails_generators/rotten_scaffold/templates/views/haml/new.html.haml +7 -0
- data/rails_generators/rotten_scaffold/templates/views/haml/show.html.haml +20 -0
- data/spec/rotten_spec.rb +7 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +9 -0
- metadata +143 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# password: "secret"
|
|
2
|
+
one:
|
|
3
|
+
username: foo
|
|
4
|
+
email: foo@example.com
|
|
5
|
+
password_hash: 3488f5f7efecab14b91eb96169e5e1ee518a569f
|
|
6
|
+
password_salt: bef65e058905c379436d80d1a32e7374b139e7b0
|
|
7
|
+
|
|
8
|
+
two:
|
|
9
|
+
username: bar
|
|
10
|
+
email: bar@example.com
|
|
11
|
+
password_hash: 3488f5f7efecab14b91eb96169e5e1ee518a569f
|
|
12
|
+
password_salt: bef65e058905c379436d80d1a32e7374b139e7b0
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class Create<%= user_plural_class_name %> < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :<%= user_plural_name %> do |t|
|
|
4
|
+
t.column :username, :string
|
|
5
|
+
t.column :email, :string
|
|
6
|
+
t.column :password_hash, :string
|
|
7
|
+
t.column :password_salt, :string
|
|
8
|
+
t.timestamps
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.down
|
|
13
|
+
drop_table :<%= user_plural_name %>
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class <%= sessions_class_name %>Controller < ApplicationController
|
|
2
|
+
def new
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
def create
|
|
6
|
+
<%= user_singular_name %> = <%= user_class_name %>.authenticate(params[:login], params[:password])
|
|
7
|
+
if <%= user_singular_name %>
|
|
8
|
+
session[:<%= user_singular_name %>_id] = <%= user_singular_name %>.id
|
|
9
|
+
flash[:notice] = "Logged in successfully."
|
|
10
|
+
redirect_to root_url
|
|
11
|
+
else
|
|
12
|
+
flash.now[:error] = "Invalid login or password."
|
|
13
|
+
render :action => 'new'
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def destroy
|
|
18
|
+
session[:<%= user_singular_name %>_id] = nil
|
|
19
|
+
flash[:notice] = "You have been logged out."
|
|
20
|
+
redirect_to root_url
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe <%= sessions_class_name %>Controller do
|
|
4
|
+
fixtures :all
|
|
5
|
+
integrate_views
|
|
6
|
+
|
|
7
|
+
it "new action should render new template" do
|
|
8
|
+
get :new
|
|
9
|
+
response.should render_template(:new)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "create action should render new template when authentication is invalid" do
|
|
13
|
+
<%= user_class_name %>.stubs(:authenticate).returns(nil)
|
|
14
|
+
post :create
|
|
15
|
+
response.should render_template(:new)
|
|
16
|
+
session['<%= user_singular_name %>_id'].should be_nil
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "create action should redirect when authentication is valid" do
|
|
20
|
+
<%= user_class_name %>.stubs(:authenticate).returns(<%= user_class_name %>.first)
|
|
21
|
+
post :create
|
|
22
|
+
response.should redirect_to(root_url)
|
|
23
|
+
session['<%= user_singular_name %>_id'].should == <%= user_class_name %>.first.id
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe <%= user_class_name %> do
|
|
4
|
+
def new_<%= user_singular_name %>(attributes = {})
|
|
5
|
+
attributes[:username] ||= 'foo'
|
|
6
|
+
attributes[:email] ||= 'foo@example.com'
|
|
7
|
+
attributes[:password] ||= 'abc123'
|
|
8
|
+
attributes[:password_confirmation] ||= attributes[:password]
|
|
9
|
+
<%= user_class_name %>.new(attributes)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
before(:each) do
|
|
13
|
+
<%= user_class_name %>.delete_all
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should be valid" do
|
|
17
|
+
new_<%= user_singular_name %>.should be_valid
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should require username" do
|
|
21
|
+
new_<%= user_singular_name %>(:username => '').should have(1).error_on(:username)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should require password" do
|
|
25
|
+
new_<%= user_singular_name %>(:password => '').should have(1).error_on(:password)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should require well formed email" do
|
|
29
|
+
new_<%= user_singular_name %>(:email => 'foo@bar@example.com').should have(1).error_on(:email)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should validate uniqueness of email" do
|
|
33
|
+
new_<%= user_singular_name %>(:email => 'bar@example.com').save!
|
|
34
|
+
new_<%= user_singular_name %>(:email => 'bar@example.com').should have(1).error_on(:email)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should validate uniqueness of username" do
|
|
38
|
+
new_<%= user_singular_name %>(:username => 'uniquename').save!
|
|
39
|
+
new_<%= user_singular_name %>(:username => 'uniquename').should have(1).error_on(:username)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should not allow odd characters in username" do
|
|
43
|
+
new_<%= user_singular_name %>(:username => 'odd ^&(@)').should have(1).error_on(:username)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should validate password is longer than 3 characters" do
|
|
47
|
+
new_<%= user_singular_name %>(:password => 'bad').should have(1).error_on(:password)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should require matching password confirmation" do
|
|
51
|
+
new_<%= user_singular_name %>(:password_confirmation => 'nonmatching').should have(1).error_on(:password)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should generate password hash and salt on create" do
|
|
55
|
+
<%= user_singular_name %> = new_<%= user_singular_name %>
|
|
56
|
+
<%= user_singular_name %>.save!
|
|
57
|
+
<%= user_singular_name %>.password_hash.should_not be_nil
|
|
58
|
+
<%= user_singular_name %>.password_salt.should_not be_nil
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "should authenticate by username" do
|
|
62
|
+
<%= user_singular_name %> = new_<%= user_singular_name %>(:username => 'foobar', :password => 'secret')
|
|
63
|
+
<%= user_singular_name %>.save!
|
|
64
|
+
<%= user_class_name %>.authenticate('foobar', 'secret').should == <%= user_singular_name %>
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "should authenticate by email" do
|
|
68
|
+
<%= user_singular_name %> = new_<%= user_singular_name %>(:email => 'foo@bar.com', :password => 'secret')
|
|
69
|
+
<%= user_singular_name %>.save!
|
|
70
|
+
<%= user_class_name %>.authenticate('foo@bar.com', 'secret').should == <%= user_singular_name %>
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "should not authenticate bad username" do
|
|
74
|
+
<%= user_class_name %>.authenticate('nonexisting', 'secret').should be_nil
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "should not authenticate bad password" do
|
|
78
|
+
new_<%= user_singular_name %>(:username => 'foobar', :password => 'secret').save!
|
|
79
|
+
<%= user_class_name %>.authenticate('foobar', 'badpassword').should be_nil
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe <%= user_plural_class_name %>Controller do
|
|
4
|
+
fixtures :all
|
|
5
|
+
integrate_views
|
|
6
|
+
|
|
7
|
+
it "new action should render new template" do
|
|
8
|
+
get :new
|
|
9
|
+
response.should render_template(:new)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "create action should render new template when model is invalid" do
|
|
13
|
+
<%= user_class_name %>.any_instance.stubs(:valid?).returns(false)
|
|
14
|
+
post :create
|
|
15
|
+
response.should render_template(:new)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "create action should redirect when model is valid" do
|
|
19
|
+
<%= user_class_name %>.any_instance.stubs(:valid?).returns(true)
|
|
20
|
+
post :create
|
|
21
|
+
response.should redirect_to(root_url)
|
|
22
|
+
session['<%= user_singular_name %>_id'].should == assigns['<%= user_singular_name %>'].id
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
class <%= user_class_name %> < ActiveRecord::Base
|
|
2
|
+
# new columns need to be added here to be writable through mass assignment
|
|
3
|
+
attr_accessible :username, :email, :password, :password_confirmation
|
|
4
|
+
|
|
5
|
+
attr_accessor :password
|
|
6
|
+
before_save :prepare_password
|
|
7
|
+
|
|
8
|
+
validates_presence_of :username
|
|
9
|
+
validates_uniqueness_of :username, :email, :allow_blank => true
|
|
10
|
+
validates_format_of :username, :with => /^[-\w\._@]+$/i, :allow_blank => true, :message => "should only contain letters, numbers, or .-_@"
|
|
11
|
+
validates_format_of :email, :with => /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i
|
|
12
|
+
validates_presence_of :password, :on => :create
|
|
13
|
+
validates_confirmation_of :password
|
|
14
|
+
validates_length_of :password, :minimum => 4, :allow_blank => true
|
|
15
|
+
|
|
16
|
+
# login can be either username or email address
|
|
17
|
+
def self.authenticate(login, pass)
|
|
18
|
+
<%= user_singular_name %> = find_by_username(login) || find_by_email(login)
|
|
19
|
+
return <%= user_singular_name %> if <%= user_singular_name %> && <%= user_singular_name %>.matching_password?(pass)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def matching_password?(pass)
|
|
23
|
+
self.password_hash == encrypt_password(pass)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def prepare_password
|
|
29
|
+
unless password.blank?
|
|
30
|
+
self.password_salt = Digest::SHA1.hexdigest([Time.now, rand].join)
|
|
31
|
+
self.password_hash = encrypt_password(password)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def encrypt_password(pass)
|
|
36
|
+
Digest::SHA1.hexdigest([pass, password_salt].join)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class <%= user_plural_class_name %>Controller < ApplicationController
|
|
2
|
+
def new
|
|
3
|
+
@<%= user_singular_name %> = <%= user_class_name %>.new
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def create
|
|
7
|
+
@<%= user_singular_name %> = <%= user_class_name %>.new(params[:<%= user_singular_name %>])
|
|
8
|
+
if @<%= user_singular_name %>.save
|
|
9
|
+
session[:<%= user_singular_name %>_id] = @<%= user_singular_name %>.id
|
|
10
|
+
flash[:notice] = "Thank you for signing up! You are now logged in."
|
|
11
|
+
redirect_to root_url
|
|
12
|
+
else
|
|
13
|
+
render :action => 'new'
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
- title "Log in"
|
|
2
|
+
|
|
3
|
+
%p== Don't have an account? #{link_to "Sign up!", signup_path}
|
|
4
|
+
|
|
5
|
+
- form_tag <%= sessions_underscore_name %>_path do
|
|
6
|
+
%p
|
|
7
|
+
= label_tag :login, "Username or Email Address"
|
|
8
|
+
%br
|
|
9
|
+
= text_field_tag :login, params[:login]
|
|
10
|
+
%p
|
|
11
|
+
= label_tag :password
|
|
12
|
+
%br
|
|
13
|
+
= password_field_tag :password
|
|
14
|
+
%p
|
|
15
|
+
= submit_tag "Log in"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
- title "Sign up"
|
|
2
|
+
|
|
3
|
+
%p== Already have an account? #{link_to "Log in", login_path}.
|
|
4
|
+
|
|
5
|
+
- form_for @<%= user_singular_name %> do |f|
|
|
6
|
+
= f.error_messages
|
|
7
|
+
%p
|
|
8
|
+
= f.label :username
|
|
9
|
+
%br
|
|
10
|
+
= f.text_field :username
|
|
11
|
+
%p
|
|
12
|
+
= f.label :email, "Email Address"
|
|
13
|
+
%br
|
|
14
|
+
= f.text_field :email
|
|
15
|
+
%p
|
|
16
|
+
= f.label :password
|
|
17
|
+
%br
|
|
18
|
+
= f.password_field :password
|
|
19
|
+
%p
|
|
20
|
+
= f.label :password_confirmation, "Confirm Password"
|
|
21
|
+
%br
|
|
22
|
+
= f.password_field :password_confirmation
|
|
23
|
+
%p
|
|
24
|
+
= f.submit "Sign up"
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#require 'rails_generator/generators/components/controller/controller_generator'
|
|
2
|
+
|
|
3
|
+
class RottenControllerGenerator < Rails::Generator::NamedBase
|
|
4
|
+
|
|
5
|
+
def manifest
|
|
6
|
+
record do |m|
|
|
7
|
+
# Check for class naming collisions.
|
|
8
|
+
m.class_collisions class_path, "#{class_name}Controller", "#{class_name}Helper"
|
|
9
|
+
|
|
10
|
+
# Controller, helper, views, and spec directories.
|
|
11
|
+
m.directory File.join('app/controllers', class_path)
|
|
12
|
+
m.directory File.join('app/helpers', class_path)
|
|
13
|
+
m.directory File.join('app/views', class_path, file_name)
|
|
14
|
+
m.directory File.join('spec/controllers', class_path)
|
|
15
|
+
m.directory File.join('spec/helpers', class_path)
|
|
16
|
+
m.directory File.join('spec/views', class_path, file_name)
|
|
17
|
+
|
|
18
|
+
@default_file_extension = "html.haml"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# Controller spec, class, and helper.
|
|
22
|
+
m.template 'controller_spec.rb',
|
|
23
|
+
File.join('spec/controllers', class_path, "#{file_name}_controller_spec.rb")
|
|
24
|
+
|
|
25
|
+
m.template 'helper_spec.rb',
|
|
26
|
+
File.join('spec/helpers', class_path, "#{file_name}_helper_spec.rb")
|
|
27
|
+
|
|
28
|
+
m.template 'controller:controller.rb',
|
|
29
|
+
File.join('app/controllers', class_path, "#{file_name}_controller.rb")
|
|
30
|
+
|
|
31
|
+
m.template 'controller:helper.rb',
|
|
32
|
+
File.join('app/helpers', class_path, "#{file_name}_helper.rb")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# View template for each action.
|
|
36
|
+
actions.each do |action|
|
|
37
|
+
|
|
38
|
+
spec_path = File.join('spec/views', class_path, file_name, "#{action}.html.haml_spec.rb")
|
|
39
|
+
path = File.join('app/views', class_path, file_name, "#{action}.html.haml")
|
|
40
|
+
|
|
41
|
+
m.template 'view_spec.rb',
|
|
42
|
+
spec_path,
|
|
43
|
+
:assigns => { :action => action, :model => file_name }
|
|
44
|
+
|
|
45
|
+
m.template 'view.html.haml',
|
|
46
|
+
path,
|
|
47
|
+
:assigns => { :action => action, :path => path }
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
class <%= class_name %>Controller < ApplicationController
|
|
2
|
+
|
|
3
|
+
layout "two_column_right"
|
|
4
|
+
|
|
5
|
+
# index
|
|
6
|
+
# GET /articles
|
|
7
|
+
# GET /articles.xml
|
|
8
|
+
#
|
|
9
|
+
# show
|
|
10
|
+
# GET /articles/1
|
|
11
|
+
# GET /articles/1.xml
|
|
12
|
+
#
|
|
13
|
+
# new
|
|
14
|
+
# GET /articles/new
|
|
15
|
+
# GET /articles/new.xml
|
|
16
|
+
#
|
|
17
|
+
# edit
|
|
18
|
+
# GET /articles/1/edit
|
|
19
|
+
#
|
|
20
|
+
# create
|
|
21
|
+
# POST /articles
|
|
22
|
+
# POST /articles.xml
|
|
23
|
+
#
|
|
24
|
+
# put
|
|
25
|
+
# PUT /articles/1
|
|
26
|
+
# PUT /articles/1.xml
|
|
27
|
+
#
|
|
28
|
+
# delete
|
|
29
|
+
# DELETE /articles/1
|
|
30
|
+
# DELETE /articles/1.xml
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
<% for action in actions -%>
|
|
34
|
+
def <%= action %>
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
<% end -%>
|
|
38
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
|
|
2
|
+
|
|
3
|
+
describe <%= class_name %>Controller do
|
|
4
|
+
|
|
5
|
+
<% if actions.empty? -%>
|
|
6
|
+
#Delete this example and add some real ones
|
|
7
|
+
<% else -%>
|
|
8
|
+
#Delete these examples and add some real ones
|
|
9
|
+
<% end -%>
|
|
10
|
+
it "should use <%= class_name %>Controller" do
|
|
11
|
+
controller.should be_an_instance_of(<%= class_name %>Controller)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
<% unless actions.empty? -%>
|
|
15
|
+
<% for action in actions -%>
|
|
16
|
+
|
|
17
|
+
describe "GET '<%= action %>'" do
|
|
18
|
+
it "should be successful" do
|
|
19
|
+
get '<%= action %>'
|
|
20
|
+
response.should be_success
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
<% end -%>
|
|
24
|
+
<% end -%>
|
|
25
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
|
|
2
|
+
|
|
3
|
+
describe <%= class_name %>Helper do
|
|
4
|
+
|
|
5
|
+
#Delete this example and add some real ones or delete this file
|
|
6
|
+
it "should be included in the object returned by #helper" do
|
|
7
|
+
included_modules = (class << helper; self; end).send :included_modules
|
|
8
|
+
included_modules.should include(<%= class_name %>Helper)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
|
|
2
|
+
|
|
3
|
+
describe "/<%= class_name.underscore %>/<%= action %>" do
|
|
4
|
+
before(:each) do
|
|
5
|
+
render '<%= class_name.underscore %>/<%= action %>'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
#Delete this example and add some real ones or delete this file
|
|
9
|
+
it "should tell you where to find the file" do
|
|
10
|
+
response.should have_tag('p', %r[Find me in app/views/<%= class_name.underscore %>/<%= action %>])
|
|
11
|
+
end
|
|
12
|
+
end
|