genesis_rails 0.0.1
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +37 -0
- data/config/routes.rb +2 -0
- data/lib/genesis_rails.rb +5 -0
- data/lib/genesis_rails/engine.rb +4 -0
- data/lib/genesis_rails/railtie.rb +7 -0
- data/lib/genesis_rails/templates/active_record/model/model.rb +22 -0
- data/lib/genesis_rails/templates/erb/scaffold/_form.html.erb +23 -0
- data/lib/genesis_rails/templates/erb/scaffold/edit.html.erb +11 -0
- data/lib/genesis_rails/templates/erb/scaffold/index.html.erb +40 -0
- data/lib/genesis_rails/templates/erb/scaffold/new.html.erb +9 -0
- data/lib/genesis_rails/templates/erb/scaffold/show.html.erb +25 -0
- data/lib/genesis_rails/templates/rails/scaffold_controller/controller.rb +62 -0
- data/lib/genesis_rails/templates/rspec/scaffold/controller_spec.rb +163 -0
- data/lib/genesis_rails/version.rb +3 -0
- data/lib/tasks/genesis_rails_tasks.rake +4 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +56 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/genesis_rails_test.rb +7 -0
- data/test/integration/navigation_test.rb +8 -0
- data/test/test_helper.rb +20 -0
- metadata +152 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b17f0ff338a2ad985f8d9cf0cc923d25ecc74557
|
4
|
+
data.tar.gz: e1cde69483cbd22b0777632fa4ba92609e20c4d5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 44427150a0545615b2745b4611a8443e9f8c5e70ec2fbf9d015beb26099db2e907ecea95f1ed903deff0b67c18092f42547429fa0274b0743199094a98e6e759
|
7
|
+
data.tar.gz: 5413b89ee14db786a6da4ebb9a30a5b470e1c731dafeb262e6def463bcbdccd1dd517cb41c5abdfab70ed54f2b6389050cecac6ba24fbc26c65db9902f345937
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2016 kelvinst
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'GenesisRails'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task default: :test
|
data/config/routes.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
<% module_namespacing do -%>
|
2
|
+
class <%= class_name %> < <%= parent_class_name.classify %>
|
3
|
+
<% attributes.select(&:reference?).each do |attribute| -%>
|
4
|
+
belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? %><%= ', required: true' if attribute.required? %>
|
5
|
+
<% end -%>
|
6
|
+
<% if attributes.any?(&:password_digest?) -%>
|
7
|
+
has_secure_password
|
8
|
+
<% end -%>
|
9
|
+
<%
|
10
|
+
attributes_to_show = attributes.reject(&:password_digest?)
|
11
|
+
title_attribute = attributes_to_show.find do |attr|
|
12
|
+
["name", "title"].include? attr.name
|
13
|
+
end || attributes_to_show.first
|
14
|
+
-%>
|
15
|
+
<% if title_attribute.present? -%>
|
16
|
+
def to_s
|
17
|
+
<%= title_attribute.name %>
|
18
|
+
end
|
19
|
+
<% end -%>
|
20
|
+
end
|
21
|
+
<% end -%>
|
22
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<div class="col-xs-10 col-xs-offset-1
|
2
|
+
col-sm-8 col-sm-offset-2
|
3
|
+
col-md-6 col-md-offset-3
|
4
|
+
col-lg-4 col-lg-offset-4">
|
5
|
+
<div class="panel">
|
6
|
+
<div class="panel-body">
|
7
|
+
<%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
|
8
|
+
<%%= form_errors_for @<%= singular_table_name %> %>
|
9
|
+
|
10
|
+
<div class="form-inputs">
|
11
|
+
<%- attributes.each do |attribute| -%>
|
12
|
+
<%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
|
13
|
+
<%- end -%>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div class="form-actions">
|
17
|
+
<%%= f.button :submit, class: "btn btn-primary pull-right" %>
|
18
|
+
</div>
|
19
|
+
<%% end %>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<h1 class="text-center mb5">
|
2
|
+
Editing <%= singular_table_name.titleize %> - <%%= @<%= singular_table_name %> %>
|
3
|
+
</h1>
|
4
|
+
|
5
|
+
<div class="text-center mb15">
|
6
|
+
<%%= link_to 'Show', @<%= singular_table_name %> %> |
|
7
|
+
<%%= link_to 'Back', <%= index_helper %>_path %>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<%%= render 'form', <%= singular_table_name %>: @<%= singular_table_name %> %>
|
11
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<h1 class="text-center mb5"><%= plural_table_name.titleize %></h1>
|
2
|
+
|
3
|
+
<div class="text-center mb15">
|
4
|
+
<%%= link_to 'New <%= singular_table_name.titleize %>', new_<%= singular_table_name %>_path %>
|
5
|
+
</div>
|
6
|
+
|
7
|
+
<div class="panel">
|
8
|
+
<div class="panel-body">
|
9
|
+
<div class="table-responsive">
|
10
|
+
<table class="table">
|
11
|
+
<thead>
|
12
|
+
<tr>
|
13
|
+
<% attributes.reject(&:password_digest?).each do |attribute| -%>
|
14
|
+
<th><%= attribute.human_name %></th>
|
15
|
+
<% end -%>
|
16
|
+
<th colspan="3"></th>
|
17
|
+
</tr>
|
18
|
+
</thead>
|
19
|
+
|
20
|
+
<tbody>
|
21
|
+
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
|
22
|
+
<tr>
|
23
|
+
<% attributes.reject(&:password_digest?).each do |attribute| -%>
|
24
|
+
<td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
|
25
|
+
<% end -%>
|
26
|
+
<td class="action"><%%= link_to 'Show', <%= singular_table_name %>,
|
27
|
+
class: "btn btn-sm btn-block btn-default" %></td>
|
28
|
+
<td class="action"><%%= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>),
|
29
|
+
class: "btn btn-sm btn-block btn-primary" %></td>
|
30
|
+
<td class="action"><%%= link_to 'Destroy', <%= singular_table_name %>,
|
31
|
+
class: "btn btn-sm btn-block btn-danger",
|
32
|
+
method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
33
|
+
</tr>
|
34
|
+
<%% end %>
|
35
|
+
</tbody>
|
36
|
+
</table>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<h1 class="text-center mb5">
|
2
|
+
<%= singular_table_name.titleize %> - <%%= @<%= singular_table_name %> %>
|
3
|
+
</h1>
|
4
|
+
|
5
|
+
<div class="text-center mb15">
|
6
|
+
<%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) %> |
|
7
|
+
<%%= link_to 'Back', <%= index_helper %>_path %>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="col-xs-10 col-xs-offset-1
|
11
|
+
col-sm-8 col-sm-offset-2
|
12
|
+
col-md-6 col-md-offset-3
|
13
|
+
col-lg-4 col-lg-offset-4">
|
14
|
+
<div class="panel">
|
15
|
+
<div class="panel-body">
|
16
|
+
<% attributes.reject(&:password_digest?).each do |attribute| -%>
|
17
|
+
<p>
|
18
|
+
<strong><%= attribute.human_name %>:</strong>
|
19
|
+
<%%= @<%= singular_table_name %>.<%= attribute.name %> %>
|
20
|
+
</p>
|
21
|
+
<% end -%>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
<% if namespaced? -%>
|
2
|
+
require_dependency "<%= namespaced_path %>/authenticated_controller"
|
3
|
+
|
4
|
+
<% end -%>
|
5
|
+
<% module_namespacing do -%>
|
6
|
+
class <%= controller_class_name %>Controller < AuthenticatedController
|
7
|
+
respond_to :html
|
8
|
+
|
9
|
+
def index
|
10
|
+
@<%= plural_table_name %> = <%= orm_class.all(class_name) %>
|
11
|
+
end
|
12
|
+
|
13
|
+
def show
|
14
|
+
load_<%= singular_table_name %>
|
15
|
+
end
|
16
|
+
|
17
|
+
def new
|
18
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name) %>
|
19
|
+
end
|
20
|
+
|
21
|
+
def edit
|
22
|
+
load_<%= singular_table_name %>
|
23
|
+
end
|
24
|
+
|
25
|
+
def create
|
26
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>
|
27
|
+
BasicServices::Create.new(@<%= singular_table_name %>).execute
|
28
|
+
|
29
|
+
respond_with @<%= singular_table_name %>
|
30
|
+
end
|
31
|
+
|
32
|
+
def update
|
33
|
+
load_<%= singular_table_name %>
|
34
|
+
@<%= singular_table_name %>.attributes = <%= singular_table_name %>_params
|
35
|
+
BasicServices::Update.new(@<%= singular_table_name %>).execute
|
36
|
+
|
37
|
+
respond_with @<%= singular_table_name %>
|
38
|
+
end
|
39
|
+
|
40
|
+
def destroy
|
41
|
+
load_<%= singular_table_name %>
|
42
|
+
BasicServices::Destroy.new(@<%= singular_table_name %>).execute
|
43
|
+
|
44
|
+
respond_with @<%= singular_table_name %>
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def load_<%= singular_table_name %>
|
50
|
+
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
51
|
+
end
|
52
|
+
|
53
|
+
def <%= "#{singular_table_name}_params" %>
|
54
|
+
<%- if attributes_names.empty? -%>
|
55
|
+
params.fetch(:<%= singular_table_name %>, {})
|
56
|
+
<%- else -%>
|
57
|
+
params.require(:<%= singular_table_name %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
|
58
|
+
<%- end -%>
|
59
|
+
end
|
60
|
+
end
|
61
|
+
<% end -%>
|
62
|
+
|
@@ -0,0 +1,163 @@
|
|
1
|
+
require 'rails_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
|
+
<% module_namespacing do -%>
|
22
|
+
RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:controller) %> do
|
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
|
+
# adjust the attributes here as well.
|
27
|
+
let(:valid_attributes) {
|
28
|
+
skip("Add a hash of attributes valid for your model")
|
29
|
+
}
|
30
|
+
|
31
|
+
let(:invalid_attributes) {
|
32
|
+
skip("Add a hash of attributes invalid for your model")
|
33
|
+
}
|
34
|
+
|
35
|
+
# This should return the minimal set of values that should be in the session
|
36
|
+
# in order to pass any filters (e.g. authentication) defined in
|
37
|
+
# <%= controller_class_name %>Controller. Be sure to keep this updated too.
|
38
|
+
let(:valid_session) { valid_session_hash }
|
39
|
+
|
40
|
+
<% unless options[:singleton] -%>
|
41
|
+
describe "GET #index" do
|
42
|
+
it "assigns all <%= table_name.pluralize %> as @<%= table_name.pluralize %>" do
|
43
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
44
|
+
get :index, {}, valid_session
|
45
|
+
expect(assigns(:<%= table_name %>)).to eq([<%= file_name %>])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
<% end -%>
|
50
|
+
describe "GET #show" do
|
51
|
+
it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
|
52
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
53
|
+
get :show, {:id => <%= file_name %>.to_param}, valid_session
|
54
|
+
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "GET #new" do
|
59
|
+
it "assigns a new <%= ns_file_name %> as @<%= ns_file_name %>" do
|
60
|
+
get :new, {}, valid_session
|
61
|
+
expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "GET #edit" do
|
66
|
+
it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
|
67
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
68
|
+
get :edit, {:id => <%= file_name %>.to_param}, valid_session
|
69
|
+
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "POST #create" do
|
74
|
+
context "with valid params" do
|
75
|
+
it "creates a new <%= class_name %>" do
|
76
|
+
expect {
|
77
|
+
post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
|
78
|
+
}.to change(<%= class_name %>, :count).by(1)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "assigns a newly created <%= ns_file_name %> as @<%= ns_file_name %>" do
|
82
|
+
post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
|
83
|
+
expect(assigns(:<%= ns_file_name %>)).to be_a(<%= class_name %>)
|
84
|
+
expect(assigns(:<%= ns_file_name %>)).to be_persisted
|
85
|
+
end
|
86
|
+
|
87
|
+
it "redirects to the created <%= ns_file_name %>" do
|
88
|
+
post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
|
89
|
+
expect(response).to redirect_to(<%= class_name %>.last)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "with invalid params" do
|
94
|
+
it "assigns a newly created but unsaved <%= ns_file_name %> as @<%= ns_file_name %>" do
|
95
|
+
post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session
|
96
|
+
expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "re-renders the 'new' template" do
|
100
|
+
post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session
|
101
|
+
expect(response).to render_template("new")
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "PUT #update" do
|
107
|
+
context "with valid params" do
|
108
|
+
let(:new_attributes) {
|
109
|
+
skip("Add a hash of attributes valid for your model")
|
110
|
+
}
|
111
|
+
|
112
|
+
it "updates the requested <%= ns_file_name %>" do
|
113
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
114
|
+
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => new_attributes}, valid_session
|
115
|
+
<%= file_name %>.reload
|
116
|
+
skip("Add assertions for updated state")
|
117
|
+
end
|
118
|
+
|
119
|
+
it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
|
120
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
121
|
+
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
|
122
|
+
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
123
|
+
end
|
124
|
+
|
125
|
+
it "redirects to the <%= ns_file_name %>" do
|
126
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
127
|
+
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
|
128
|
+
expect(response).to redirect_to(<%= file_name %>)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context "with invalid params" do
|
133
|
+
it "assigns the <%= ns_file_name %> as @<%= ns_file_name %>" do
|
134
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
135
|
+
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session
|
136
|
+
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
137
|
+
end
|
138
|
+
|
139
|
+
it "re-renders the 'edit' template" do
|
140
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
141
|
+
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session
|
142
|
+
expect(response).to render_template("edit")
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe "DELETE #destroy" do
|
148
|
+
it "destroys the requested <%= ns_file_name %>" do
|
149
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
150
|
+
expect {
|
151
|
+
delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
|
152
|
+
}.to change(<%= class_name %>, :count).by(-1)
|
153
|
+
end
|
154
|
+
|
155
|
+
it "redirects to the <%= table_name %> list" do
|
156
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
157
|
+
delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
|
158
|
+
expect(response).to redirect_to(<%= index_helper %>_url)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
163
|
+
<% end -%>
|