stationed 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +20 -0
- data/README.md +136 -0
- data/Rakefile +27 -0
- data/app/helpers/crud_link_helper.rb +22 -0
- data/app/helpers/page_title_helper.rb +107 -0
- data/lib/generators/stationed/templates_generator.rb +24 -0
- data/lib/stationed/app_builder.rb +13 -0
- data/lib/stationed/crud_tag.rb +70 -0
- data/lib/stationed/engine.rb +8 -0
- data/lib/stationed/generators/app_generator.rb +52 -0
- data/lib/stationed/generators/plugins/capybara.rb +12 -0
- data/lib/stationed/generators/plugins/capybara_webkit.rb +14 -0
- data/lib/stationed/generators/plugins/database_cleaner.rb +13 -0
- data/lib/stationed/generators/plugins/devise.rb +43 -0
- data/lib/stationed/generators/plugins/draper.rb +14 -0
- data/lib/stationed/generators/plugins/factory_girl.rb +14 -0
- data/lib/stationed/generators/plugins/flashes.rb +12 -0
- data/lib/stationed/generators/plugins/foreman.rb +15 -0
- data/lib/stationed/generators/plugins/generators.rb +12 -0
- data/lib/stationed/generators/plugins/guard.rb +26 -0
- data/lib/stationed/generators/plugins/haml.rb +12 -0
- data/lib/stationed/generators/plugins/i18n_spec.rb +13 -0
- data/lib/stationed/generators/plugins/kaminari.rb +18 -0
- data/lib/stationed/generators/plugins/layout.rb +13 -0
- data/lib/stationed/generators/plugins/normalize.rb +12 -0
- data/lib/stationed/generators/plugins/pry.rb +19 -0
- data/lib/stationed/generators/plugins/pundit.rb +20 -0
- data/lib/stationed/generators/plugins/rack_deflater.rb +17 -0
- data/lib/stationed/generators/plugins/responders.rb +28 -0
- data/lib/stationed/generators/plugins/rspec.rb +21 -0
- data/lib/stationed/generators/plugins/rubocop.rb +14 -0
- data/lib/stationed/generators/plugins/simple_form.rb +32 -0
- data/lib/stationed/generators/plugins/simple_form_inputs.rb +13 -0
- data/lib/stationed/generators/plugins/spring.rb +13 -0
- data/lib/stationed/generators/plugins/stationed.rb +12 -0
- data/lib/stationed/generators/plugins/strong_parameters.rb +18 -0
- data/lib/stationed/generators/plugins/styles.rb +24 -0
- data/lib/stationed/generators/plugins/turbolinks.rb +13 -0
- data/lib/stationed/generators/plugins/webmock.rb +13 -0
- data/lib/stationed/generators/plugins/wiki.rb +20 -0
- data/lib/stationed/generators/plugins/yard.rb +14 -0
- data/lib/stationed/generators/plugins.rb +10 -0
- data/lib/stationed/generators/templates/Deployment.md +3 -0
- data/lib/stationed/generators/templates/Home.md +8 -0
- data/lib/stationed/generators/templates/Procfile +1 -0
- data/lib/stationed/generators/templates/README.md.erb +42 -0
- data/lib/stationed/generators/templates/Services.md +3 -0
- data/lib/stationed/generators/templates/Setup.md +58 -0
- data/lib/stationed/generators/templates/Testing.md +3 -0
- data/lib/stationed/generators/templates/application.html.haml +11 -0
- data/lib/stationed/generators/templates/application.scss +6 -0
- data/lib/stationed/generators/templates/application_decorator.rb +23 -0
- data/lib/stationed/generators/templates/application_responder.rb +6 -0
- data/lib/stationed/generators/templates/authorization.rb +11 -0
- data/lib/stationed/generators/templates/capybara_webkit.rb +1 -0
- data/lib/stationed/generators/templates/database_cleaner.rb +19 -0
- data/lib/stationed/generators/templates/devise.rb +3 -0
- data/lib/stationed/generators/templates/env.erb +3 -0
- data/lib/stationed/generators/templates/factories_spec.rb +10 -0
- data/lib/stationed/generators/templates/factory_girl.rb +3 -0
- data/lib/stationed/generators/templates/flashes.html.haml +5 -0
- data/lib/stationed/generators/templates/generators.rb +11 -0
- data/lib/stationed/generators/templates/gollum.rake +5 -0
- data/lib/stationed/generators/templates/gollum.rb +5 -0
- data/lib/stationed/generators/templates/i18n_spec.rb +10 -0
- data/lib/stationed/generators/templates/layout.scss +3 -0
- data/lib/stationed/generators/templates/normalize.css +425 -0
- data/lib/stationed/generators/templates/paginating_decorator.rb +7 -0
- data/lib/stationed/generators/templates/pundit.rb +1 -0
- data/lib/stationed/generators/templates/rubocop.rake +5 -0
- data/lib/stationed/generators/templates/rubocop.yml +38 -0
- data/lib/stationed/generators/templates/select2_input.rb +14 -0
- data/lib/stationed/generators/templates/simple_form.rb +65 -0
- data/lib/stationed/generators/templates/simplecov +6 -0
- data/lib/stationed/generators/templates/spec_helper.rb +27 -0
- data/lib/stationed/generators/templates/spring.rb +1 -0
- data/lib/stationed/generators/templates/static_input.rb +11 -0
- data/lib/stationed/generators/templates/webmock.rb +1 -0
- data/lib/stationed/generators/templates/yardopts +7 -0
- data/lib/stationed/version.rb +3 -0
- data/lib/stationed.rb +4 -0
- data/lib/tasks/stationed_tasks.rake +4 -0
- data/lib/templates/haml/scaffold/_form.html.haml +11 -0
- data/lib/templates/haml/scaffold/edit.html.haml +2 -0
- data/lib/templates/haml/scaffold/index.html.haml +24 -0
- data/lib/templates/haml/scaffold/new.html.haml +2 -0
- data/lib/templates/haml/scaffold/show.html.haml +9 -0
- data/lib/templates/rails/scaffold_controller/controller.rb +64 -0
- data/lib/templates/rspec/integration/request_spec.rb +10 -0
- data/lib/templates/rspec/model/model_spec.rb +6 -0
- data/lib/templates/rspec/scaffold/controller_spec.rb +224 -0
- data/lib/templates/rspec/scaffold/edit_spec.rb +20 -0
- data/lib/templates/rspec/scaffold/index_spec.rb +20 -0
- data/lib/templates/rspec/scaffold/new_spec.rb +20 -0
- data/lib/templates/rspec/scaffold/routing_spec.rb +17 -0
- data/lib/templates/rspec/scaffold/show_spec.rb +14 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/test.log +1418 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/helpers/crud_link_helper_spec.rb +88 -0
- data/spec/helpers/page_title_helper_spec.rb +83 -0
- data/spec/spec_helper.rb +14 -0
- metadata +261 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
%h1= page_title @<%= plural_table_name %>
|
2
|
+
|
3
|
+
= link_to_new <%= class_name %>
|
4
|
+
|
5
|
+
%table
|
6
|
+
%thead
|
7
|
+
%tr
|
8
|
+
<%- attributes.each do |attribute| -%>
|
9
|
+
%th= <%= class_name %>.human_attribute_name(:<%= attribute.name %>)
|
10
|
+
<%- end -%>
|
11
|
+
%th
|
12
|
+
%th
|
13
|
+
%th
|
14
|
+
%tbody
|
15
|
+
- @<%= plural_table_name %>.each do |<%= singular_table_name %>|
|
16
|
+
%tr[<%= singular_table_name %>]{ class: cycle('odd', 'even') }
|
17
|
+
<%- attributes.each do |attribute| -%>
|
18
|
+
%td= <%= singular_table_name %>.<%= attribute.name %>
|
19
|
+
<%- end -%>
|
20
|
+
%td= link_to_show <%= singular_table_name %>
|
21
|
+
%td= link_to_edit <%= singular_table_name %>
|
22
|
+
%td= link_to_destroy <%= singular_table_name %>
|
23
|
+
|
24
|
+
= paginate @<%= plural_table_name %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
%h1= page_title @<%= singular_table_name %>
|
2
|
+
|
3
|
+
%dl
|
4
|
+
<% attributes.each do |attribute| %>
|
5
|
+
%dt= <%= class_name %>.human_attribute_name(:<%= attribute.name %>)
|
6
|
+
%dd= @<%= singular_table_name %>.<%= attribute.name %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
= link_to_edit @<%= singular_table_name %>
|
@@ -0,0 +1,64 @@
|
|
1
|
+
<% if namespaced? -%>
|
2
|
+
require_dependency "<%= namespaced_file_path %>/application_controller"
|
3
|
+
|
4
|
+
<% end -%>
|
5
|
+
<% module_namespacing do -%>
|
6
|
+
class <%= controller_class_name %>Controller < ApplicationController
|
7
|
+
respond_to :html, :json
|
8
|
+
before_action :set_<%= singular_table_name %>, only: %i[show edit update destroy]
|
9
|
+
|
10
|
+
def index
|
11
|
+
@<%= plural_table_name %> = policy_scope(<%= orm_class.all(class_name) %>).decorate
|
12
|
+
respond_with @<%= plural_table_name %>
|
13
|
+
end
|
14
|
+
|
15
|
+
def show
|
16
|
+
authorize @<%= singular_table_name %>
|
17
|
+
respond_with @<%= singular_table_name %>
|
18
|
+
end
|
19
|
+
|
20
|
+
def new
|
21
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name) %>.decorate
|
22
|
+
authorize @<%= singular_table_name %>
|
23
|
+
respond_with @<%= singular_table_name %>
|
24
|
+
end
|
25
|
+
|
26
|
+
def edit
|
27
|
+
authorize @<%= singular_table_name %>
|
28
|
+
respond_with @<%= singular_table_name %>
|
29
|
+
end
|
30
|
+
|
31
|
+
def create
|
32
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>
|
33
|
+
authorize @<%= singular_table_name %>
|
34
|
+
@<%= orm_instance.save %>
|
35
|
+
respond_with @<%= singular_table_name %>
|
36
|
+
end
|
37
|
+
|
38
|
+
def update
|
39
|
+
authorize @<%= singular_table_name %>
|
40
|
+
@<%= orm_instance.update("#{singular_table_name}_params") %>
|
41
|
+
respond_with @<%= singular_table_name %>
|
42
|
+
end
|
43
|
+
|
44
|
+
def destroy
|
45
|
+
authorize @<%= singular_table_name %>
|
46
|
+
@<%= orm_instance.destroy %>
|
47
|
+
respond_with @<%= singular_table_name %>
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def set_<%= singular_table_name %>
|
53
|
+
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>.decorate
|
54
|
+
end
|
55
|
+
|
56
|
+
def <%= "#{singular_table_name}_params" %>
|
57
|
+
<%- if attributes_names.empty? -%>
|
58
|
+
params[<%= ":#{singular_table_name}" %>]
|
59
|
+
<%- else -%>
|
60
|
+
params.require(<%= ":#{singular_table_name}" %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
|
61
|
+
<%- end -%>
|
62
|
+
end
|
63
|
+
end
|
64
|
+
<% end -%>
|
@@ -0,0 +1,224 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
<% module_namespacing do -%>
|
4
|
+
describe <%= controller_class_name %>Controller do
|
5
|
+
subject { response }
|
6
|
+
|
7
|
+
<% unless options[:singleton] -%>
|
8
|
+
describe 'GET index' do
|
9
|
+
let(:<%= table_name %>) { build_stubbed_list :<%= file_name %>, 2 }
|
10
|
+
|
11
|
+
before do
|
12
|
+
allow(<%= class_name %>).to receive(:all).and_return(<%= table_name %>)
|
13
|
+
<%= class_name %>Policy.any_instance.stub(:index?).and_return(true)
|
14
|
+
allow(Array).to receive(:policy_class).and_return(<%= class_name %>Policy)
|
15
|
+
allow(<%= table_name %>).to receive(:decorate).and_return(<%= table_name %>)
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'response' do
|
19
|
+
before { get :index }
|
20
|
+
it { should render_template('index') }
|
21
|
+
it { should be_success }
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'assigns all <%= table_name.pluralize %> as @<%= table_name.pluralize %>' do
|
25
|
+
get :index
|
26
|
+
expect(assigns(:<%= table_name %>)).to eq(<%= table_name %>)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'assigns decorated records' do
|
30
|
+
expect(<%= table_name %>).to receive(:decorate)
|
31
|
+
get :index
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
<% end -%>
|
36
|
+
describe 'GET show' do
|
37
|
+
let(:<%= file_name %>) { build_stubbed :<%= file_name %> }
|
38
|
+
|
39
|
+
before do
|
40
|
+
allow(<%= class_name %>).to receive(:find).with(<%= file_name %>.to_param).and_return(<%= file_name %>)
|
41
|
+
<%= class_name %>Policy.any_instance.stub(:show?).and_return(true)
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'response' do
|
45
|
+
before { get :show, id: <%= file_name %>.to_param }
|
46
|
+
it { should render_template('show') }
|
47
|
+
it { should be_success }
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>' do
|
51
|
+
get :show, id: <%= file_name %>.to_param
|
52
|
+
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'assigns decorated <%= file_name %>' do
|
56
|
+
get :show, id: <%= file_name %>.to_param
|
57
|
+
expect(assigns(:<%= ns_file_name %>)).to be_decorated
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'GET new' do
|
62
|
+
let(:<%= file_name %>) { build :<%= file_name %> }
|
63
|
+
|
64
|
+
before do
|
65
|
+
allow(<%= class_name %>).to receive(:new).and_return(<%= file_name %>)
|
66
|
+
<%= class_name %>Policy.any_instance.stub(:new?).and_return(true)
|
67
|
+
end
|
68
|
+
|
69
|
+
describe 'response' do
|
70
|
+
before { get :new }
|
71
|
+
it { should render_template('new') }
|
72
|
+
it { should be_success }
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'assigns a new <%= ns_file_name %> as @<%= ns_file_name %>' do
|
76
|
+
get :new
|
77
|
+
expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'assigns a decorated <%= ns_file_name %>' do
|
81
|
+
get :new
|
82
|
+
expect(assigns(:<%= ns_file_name %>)).to be_decorated
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe 'GET edit' do
|
87
|
+
let(:<%= file_name %>) { build_stubbed :<%= file_name %> }
|
88
|
+
|
89
|
+
before do
|
90
|
+
allow(<%= class_name %>).to receive(:find).with(<%= file_name %>.to_param).and_return(<%= file_name %>)
|
91
|
+
<%= class_name %>Policy.any_instance.stub(:edit?).and_return(true)
|
92
|
+
end
|
93
|
+
|
94
|
+
describe 'response' do
|
95
|
+
before { get :edit, id: <%= file_name %>.to_param }
|
96
|
+
it { should render_template('edit') }
|
97
|
+
it { should be_success }
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>' do
|
101
|
+
get :edit, id: <%= file_name %>.to_param
|
102
|
+
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'assigns a decorated <%= ns_file_name %>' do
|
106
|
+
get :edit, id: <%= file_name %>.to_param
|
107
|
+
expect(assigns(:<%= ns_file_name %>)).to be_decorated
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe 'POST create' do
|
112
|
+
before do
|
113
|
+
<%= class_name %>Policy.any_instance.stub(:create?).and_return(true)
|
114
|
+
end
|
115
|
+
|
116
|
+
describe 'with valid params' do
|
117
|
+
it 'creates a new <%= class_name %>' do
|
118
|
+
expect {
|
119
|
+
post :create, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
120
|
+
}.to change { <%= class_name %>.count }.by(1)
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'assigns a newly created <%= ns_file_name %> as @<%= ns_file_name %>' do
|
124
|
+
post :create, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
125
|
+
expect(assigns(:<%= ns_file_name %>)).to be_a(<%= class_name %>)
|
126
|
+
expect(assigns(:<%= ns_file_name %>)).to be_persisted
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'redirects to the created <%= ns_file_name %>' do
|
130
|
+
post :create, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
131
|
+
expect(response).to redirect_to(<%= class_name %>.last)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe 'with invalid params' do
|
136
|
+
let(:<%= file_name %>) { build :<%= file_name %> }
|
137
|
+
|
138
|
+
before do
|
139
|
+
allow(<%= class_name %>).to receive(:new).and_return(<%= file_name %>)
|
140
|
+
allow(<%= file_name %>).to receive(:save).and_return(false)
|
141
|
+
allow(<%= file_name %>).to receive(:errors).and_return(foo: 'bar')
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'assigns a newly created but unsaved <%= ns_file_name %> as @<%= ns_file_name %>' do
|
145
|
+
post :create, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
146
|
+
expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
|
147
|
+
end
|
148
|
+
|
149
|
+
it 're-renders the "new" template' do
|
150
|
+
post :create, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
151
|
+
expect(response).to render_template('new')
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe 'PUT update' do
|
157
|
+
let(:<%= file_name %>) { build_stubbed :<%= file_name %> }
|
158
|
+
|
159
|
+
before do
|
160
|
+
allow(<%= class_name %>).to receive(:find).with(<%= file_name %>.to_param).and_return(<%= file_name %>)
|
161
|
+
<%= class_name %>Policy.any_instance.stub(:update?).and_return(true)
|
162
|
+
end
|
163
|
+
|
164
|
+
describe 'with valid params' do
|
165
|
+
before do
|
166
|
+
allow(<%= file_name %>).to receive(:update).and_return(true)
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'updates the requested <%= ns_file_name %>' do
|
170
|
+
expect(<%= file_name %>).to receive(:update).with(attributes_for(:<%= file_name %>).stringify_keys)
|
171
|
+
put :update, id: <%= file_name %>.to_param, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>' do
|
175
|
+
put :update, id: <%= file_name %>.to_param, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
176
|
+
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'redirects to the <%= ns_file_name %>' do
|
180
|
+
put :update, id: <%= file_name %>.to_param, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
181
|
+
expect(response).to redirect_to(<%= file_name %>)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe 'with invalid params' do
|
186
|
+
before do
|
187
|
+
allow(<%= file_name %>).to receive(:save).and_return(false)
|
188
|
+
allow(<%= file_name %>).to receive(:errors).and_return(foo: 'bar')
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'assigns the <%= ns_file_name %> as @<%= ns_file_name %>' do
|
192
|
+
put :update, id: <%= file_name %>.to_param, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
193
|
+
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
194
|
+
end
|
195
|
+
|
196
|
+
it 're-renders the "edit" template' do
|
197
|
+
put :update, id: <%= file_name %>.to_param, <%= ns_file_name %>: attributes_for(:<%= file_name %>)
|
198
|
+
expect(response).to render_template('edit')
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe 'DELETE destroy' do
|
204
|
+
let(:<%= file_name %>) { build_stubbed :<%= file_name %> }
|
205
|
+
|
206
|
+
before do
|
207
|
+
allow(<%= class_name %>).to receive(:find).with(<%= file_name %>.to_param).and_return(<%= file_name %>)
|
208
|
+
allow(<%= file_name %>).to receive(:destroy).and_return(true)
|
209
|
+
allow(<%= file_name %>).to receive(:persisted?).and_return(false)
|
210
|
+
<%= class_name %>Policy.any_instance.stub(:destroy?).and_return(true)
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'destroys the requested <%= ns_file_name %>' do
|
214
|
+
expect(<%= file_name %>).to receive(:destroy)
|
215
|
+
delete :destroy, id: <%= file_name %>.to_param
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'redirects to the <%= table_name %> list' do
|
219
|
+
delete :destroy, id: <%= file_name %>.to_param
|
220
|
+
expect(response).to redirect_to(<%= index_helper %>_url)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
<% end -%>
|
@@ -0,0 +1,20 @@
|
|
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
|
+
let(:<%= ns_file_name %>) { build_stubbed :<%= ns_file_name %> }
|
6
|
+
|
7
|
+
before do
|
8
|
+
assign :<%= ns_file_name %>, <%= ns_file_name %>
|
9
|
+
end
|
10
|
+
|
11
|
+
it "renders the edit <%= ns_file_name %> form" do
|
12
|
+
render
|
13
|
+
|
14
|
+
assert_select "form[action=?][method=?]", <%= ns_file_name %>_path(<%= ns_file_name %>), "post" do
|
15
|
+
<% for attribute in output_attributes -%>
|
16
|
+
assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>[name=?]", "<%= ns_file_name %>[<%= attribute.name %>]"
|
17
|
+
<% end -%>
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "<%= ns_table_name %>/index" do
|
4
|
+
let(:<%= table_name %>) { build_stubbed_list :<%= ns_file_name %>, 3 }
|
5
|
+
|
6
|
+
before do
|
7
|
+
assign :<%= table_name %>, <%= table_name %>
|
8
|
+
allow(view).to receive(:paginate).and_return('pagination')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'paginates the results' do
|
12
|
+
expect(view).to receive(:paginate).with(<%= table_name %>)
|
13
|
+
render
|
14
|
+
end
|
15
|
+
|
16
|
+
it "renders a list of <%= ns_table_name %>" do
|
17
|
+
render
|
18
|
+
assert_select 'tr>td', text: 'MyString'
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
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
|
+
let(:<%= ns_file_name %>) { build :<%= ns_file_name %> }
|
6
|
+
|
7
|
+
before do
|
8
|
+
assign :<%= ns_file_name %>, <%= ns_file_name %>
|
9
|
+
end
|
10
|
+
|
11
|
+
it "renders new <%= ns_file_name %> form" do
|
12
|
+
render
|
13
|
+
|
14
|
+
assert_select "form[action=?][method=?]", <%= index_helper %>_path, "post" do
|
15
|
+
<% for attribute in output_attributes -%>
|
16
|
+
assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>[name=?]", "<%= ns_file_name %>[<%= attribute.name %>]"
|
17
|
+
<% end -%>
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
<% module_namespacing do -%>
|
4
|
+
describe <%= controller_class_name %>Controller do
|
5
|
+
describe 'routing' do
|
6
|
+
<% unless options[:singleton] -%>
|
7
|
+
it { expect(get: '/<%= ns_table_name %>').to route_to('<%= ns_table_name %>#index') }
|
8
|
+
<% end -%>
|
9
|
+
it { expect(get: '/<%= ns_table_name %>/new').to route_to('<%= ns_table_name %>#new') }
|
10
|
+
it { expect(get: '/<%= ns_table_name %>/1').to route_to('<%= ns_table_name %>#show', id: '1') }
|
11
|
+
it { expect(get: '/<%= ns_table_name %>/1/edit').to route_to('<%= ns_table_name %>#edit', id: '1') }
|
12
|
+
it { expect(post: '/<%= ns_table_name %>').to route_to('<%= ns_table_name %>#create') }
|
13
|
+
it { expect(put: '/<%= ns_table_name %>/1').to route_to('<%= ns_table_name %>#update', id: '1') }
|
14
|
+
it { expect(delete: '/<%= ns_table_name %>/1').to route_to('<%= ns_table_name %>#destroy', id: '1') }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
<% end -%>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "<%= ns_table_name %>/show" do
|
4
|
+
let(:<%= ns_file_name %>) { build_stubbed :<%= ns_file_name %> }
|
5
|
+
|
6
|
+
before do
|
7
|
+
assign :<%= ns_file_name %>, <%= ns_file_name %>
|
8
|
+
end
|
9
|
+
|
10
|
+
it "renders attributes in <p>" do
|
11
|
+
render
|
12
|
+
expect(rendered).to match(/MyString/)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
|
6
|
+
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/spec/dummy/bin/rake
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require(*Rails.groups)
|
6
|
+
require "stationed"
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
11
|
+
# Application configuration should go into files in config/initializers
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
13
|
+
|
14
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
15
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
16
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
17
|
+
|
18
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
|
+
# config.i18n.default_locale = :de
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
development:
|
7
|
+
adapter: sqlite3
|
8
|
+
database: db/development.sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
# Warning: The database defined as "test" will be erased and
|
13
|
+
# re-generated from your development database when you run "rake".
|
14
|
+
# Do not set this db to the same as development or production.
|
15
|
+
test:
|
16
|
+
adapter: sqlite3
|
17
|
+
database: db/test.sqlite3
|
18
|
+
pool: 5
|
19
|
+
timeout: 5000
|
20
|
+
|
21
|
+
production:
|
22
|
+
adapter: sqlite3
|
23
|
+
database: db/production.sqlite3
|
24
|
+
pool: 5
|
25
|
+
timeout: 5000
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Do not eager load code on boot.
|
10
|
+
config.eager_load = false
|
11
|
+
|
12
|
+
# Show full error reports and disable caching.
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send.
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger.
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Raise an error on page load if there are pending migrations
|
23
|
+
config.active_record.migration_error = :page_load
|
24
|
+
|
25
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
26
|
+
# This option may cause significant delays in view rendering with a large
|
27
|
+
# number of complex assets.
|
28
|
+
config.assets.debug = true
|
29
|
+
end
|