silmarails 0.1.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/LICENSE +22 -0
- data/README.md +188 -0
- data/Rakefile +57 -0
- data/app/assets/javascripts/magic_view.coffee +4 -0
- data/app/assets/javascripts/magic_view/init.coffee +25 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/config/routes.rb +2 -0
- data/lib/generators/silmarails/install/USAGE +8 -0
- data/lib/generators/silmarails/install/files/spec/support/silmarails.rb +33 -0
- data/lib/generators/silmarails/install/files/templates/active_record/model/model.rb +22 -0
- data/lib/generators/silmarails/install/files/templates/coffee/assets/javascript.coffee +11 -0
- data/lib/generators/silmarails/install/files/templates/erb/scaffold/_form.html.erb +23 -0
- data/lib/generators/silmarails/install/files/templates/erb/scaffold/edit.html.erb +11 -0
- data/lib/generators/silmarails/install/files/templates/erb/scaffold/index.html.erb +44 -0
- data/lib/generators/silmarails/install/files/templates/erb/scaffold/new.html.erb +9 -0
- data/lib/generators/silmarails/install/files/templates/erb/scaffold/show.html.erb +25 -0
- data/lib/generators/silmarails/install/files/templates/rails/responders_controller/controller.rb +59 -0
- data/lib/generators/silmarails/install/files/templates/rspec/scaffold/controller_spec.rb +163 -0
- data/lib/generators/silmarails/install/files/templates/rspec/scaffold/edit_spec.rb +19 -0
- data/lib/generators/silmarails/install/files/templates/rspec/scaffold/index_spec.rb +17 -0
- data/lib/generators/silmarails/install/files/templates/rspec/scaffold/new_spec.rb +19 -0
- data/lib/generators/silmarails/install/files/templates/rspec/scaffold/routing_spec.rb +45 -0
- data/lib/generators/silmarails/install/files/templates/rspec/scaffold/show_spec.rb +15 -0
- data/lib/generators/silmarails/install/install_generator.rb +22 -0
- data/lib/silmarails.rb +6 -0
- data/lib/silmarails/auto_include_magic_view.rb +52 -0
- data/lib/silmarails/engine.rb +4 -0
- data/lib/silmarails/railtie.rb +12 -0
- data/lib/silmarails/version.rb +3 -0
- data/lib/tasks/silmarails_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/lib/templates/rspec/controller/controller_spec.rb +16 -0
- data/test/dummy/lib/templates/rspec/controller/view_spec.rb +5 -0
- data/test/dummy/lib/templates/rspec/helper/helper_spec.rb +17 -0
- data/test/dummy/lib/templates/rspec/integration/request_spec.rb +10 -0
- data/test/dummy/lib/templates/rspec/mailer/fixture +3 -0
- data/test/dummy/lib/templates/rspec/mailer/mailer_spec.rb +25 -0
- data/test/dummy/lib/templates/rspec/mailer/preview.rb +13 -0
- data/test/dummy/lib/templates/rspec/model/fixtures.yml +19 -0
- data/test/dummy/lib/templates/rspec/model/model_spec.rb +7 -0
- data/test/dummy/lib/templates/rspec/observer/observer_spec.rb +7 -0
- data/test/dummy/lib/templates/rspec/scaffold/controller_spec.rb +163 -0
- data/test/dummy/lib/templates/rspec/scaffold/edit_spec.rb +23 -0
- data/test/dummy/lib/templates/rspec/scaffold/index_spec.rb +25 -0
- data/test/dummy/lib/templates/rspec/scaffold/new_spec.rb +22 -0
- data/test/dummy/lib/templates/rspec/scaffold/routing_spec.rb +45 -0
- data/test/dummy/lib/templates/rspec/scaffold/show_spec.rb +21 -0
- data/test/dummy/lib/templates/rspec/view/view_spec.rb +5 -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/integration/navigation_test.rb +8 -0
- data/test/silmarails_test.rb +7 -0
- data/test/test_helper.rb +20 -0
- metadata +227 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
11
|
+
# just for the purpose of running a single test. If you are using a tool that
|
12
|
+
# preloads Rails for running tests, you may have to set it to true.
|
13
|
+
config.eager_load = false
|
14
|
+
|
15
|
+
# Configure static file server for tests with Cache-Control for performance.
|
16
|
+
config.serve_static_files = true
|
17
|
+
config.static_cache_control = 'public, max-age=3600'
|
18
|
+
|
19
|
+
# Show full error reports and disable caching.
|
20
|
+
config.consider_all_requests_local = true
|
21
|
+
config.action_controller.perform_caching = false
|
22
|
+
|
23
|
+
# Raise exceptions instead of rendering exception templates.
|
24
|
+
config.action_dispatch.show_exceptions = false
|
25
|
+
|
26
|
+
# Disable request forgery protection in test environment.
|
27
|
+
config.action_controller.allow_forgery_protection = false
|
28
|
+
|
29
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
30
|
+
# The :test delivery method accumulates sent emails in the
|
31
|
+
# ActionMailer::Base.deliveries array.
|
32
|
+
config.action_mailer.delivery_method = :test
|
33
|
+
|
34
|
+
# Randomize the order test cases are executed.
|
35
|
+
config.active_support.test_order = :random
|
36
|
+
|
37
|
+
# Print deprecation notices to the stderr.
|
38
|
+
config.active_support.deprecation = :stderr
|
39
|
+
|
40
|
+
# Raises error for missing translations
|
41
|
+
# config.action_view.raise_on_missing_translations = true
|
42
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Version of your assets, change this if you want to expire all your assets.
|
4
|
+
Rails.application.config.assets.version = '1.0'
|
5
|
+
|
6
|
+
# Add additional assets to the asset load path
|
7
|
+
# Rails.application.config.assets.paths << Emoji.images_path
|
8
|
+
|
9
|
+
# Precompile additional assets.
|
10
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
11
|
+
# Rails.application.config.assets.precompile += %w( search.js )
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format. Inflections
|
4
|
+
# are locale specific, and you may define rules for as many different
|
5
|
+
# locales as you wish. All of these examples are active by default:
|
6
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
7
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
8
|
+
# inflect.singular /^(ox)en/i, '\1'
|
9
|
+
# inflect.irregular 'person', 'people'
|
10
|
+
# inflect.uncountable %w( fish sheep )
|
11
|
+
# end
|
12
|
+
|
13
|
+
# These inflection rules are supported but not enabled by default:
|
14
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
15
|
+
# inflect.acronym 'RESTful'
|
16
|
+
# end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
9
|
+
end
|
10
|
+
|
11
|
+
# To enable root element in JSON for ActiveRecord objects.
|
12
|
+
# ActiveSupport.on_load(:active_record) do
|
13
|
+
# self.include_root_in_json = true
|
14
|
+
# end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
+
# than English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t 'hello'
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t('hello') %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# To learn more, please read the Rails Internationalization guide
|
20
|
+
# available at http://guides.rubyonrails.org/i18n.html.
|
21
|
+
|
22
|
+
en:
|
23
|
+
hello: "Hello world"
|
@@ -0,0 +1,56 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
3
|
+
# See how all your routes lay out with "rake routes".
|
4
|
+
|
5
|
+
# You can have the root of your site routed with "root"
|
6
|
+
# root 'welcome#index'
|
7
|
+
|
8
|
+
# Example of regular route:
|
9
|
+
# get 'products/:id' => 'catalog#view'
|
10
|
+
|
11
|
+
# Example of named route that can be invoked with purchase_url(id: product.id)
|
12
|
+
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
|
13
|
+
|
14
|
+
# Example resource route (maps HTTP verbs to controller actions automatically):
|
15
|
+
# resources :products
|
16
|
+
|
17
|
+
# Example resource route with options:
|
18
|
+
# resources :products do
|
19
|
+
# member do
|
20
|
+
# get 'short'
|
21
|
+
# post 'toggle'
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# collection do
|
25
|
+
# get 'sold'
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
|
29
|
+
# Example resource route with sub-resources:
|
30
|
+
# resources :products do
|
31
|
+
# resources :comments, :sales
|
32
|
+
# resource :seller
|
33
|
+
# end
|
34
|
+
|
35
|
+
# Example resource route with more complex sub-resources:
|
36
|
+
# resources :products do
|
37
|
+
# resources :comments
|
38
|
+
# resources :sales do
|
39
|
+
# get 'recent', on: :collection
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
|
43
|
+
# Example resource route with concerns:
|
44
|
+
# concern :toggleable do
|
45
|
+
# post 'toggle'
|
46
|
+
# end
|
47
|
+
# resources :posts, concerns: :toggleable
|
48
|
+
# resources :photos, concerns: :toggleable
|
49
|
+
|
50
|
+
# Example resource route within a namespace:
|
51
|
+
# namespace :admin do
|
52
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
53
|
+
# # (app/controllers/admin/products_controller.rb)
|
54
|
+
# resources :products
|
55
|
+
# end
|
56
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
+
# You can use `rake secret` to generate a secure secret key.
|
9
|
+
|
10
|
+
# Make sure the secrets in this file are kept private
|
11
|
+
# if you're sharing your code publicly.
|
12
|
+
|
13
|
+
development:
|
14
|
+
secret_key_base: 0df984cb47df1ec397284d41fe4e65c6cf9c1b149dbfdbdc34b4af7e2bf0323484a6aeaa87fe96e8d223c7aadfcdabad9cd00f2fb3d94b731d629174a0290279
|
15
|
+
|
16
|
+
test:
|
17
|
+
secret_key_base: 8557f019102a1082114f4b870ee3c07b24ae2a13aaa46f14d142ed0e3a617f2335356e18bee0da0f74fe7df78be00c5709164c55c767fcf3d1c7cf5679f0f4cb
|
18
|
+
|
19
|
+
# Do not keep production secrets in the repository,
|
20
|
+
# instead read values from the environment.
|
21
|
+
production:
|
22
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
<% module_namespacing do -%>
|
4
|
+
RSpec.describe <%= class_name %>Controller, <%= type_metatag(:controller) %> do
|
5
|
+
|
6
|
+
<% for action in actions -%>
|
7
|
+
describe "GET #<%= action %>" do
|
8
|
+
it "returns http success" do
|
9
|
+
get :<%= action %>
|
10
|
+
expect(response).to have_http_status(:success)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
<% end -%>
|
15
|
+
end
|
16
|
+
<% end -%>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
# Specs in this file have access to a helper object that includes
|
4
|
+
# the <%= class_name %>Helper. For example:
|
5
|
+
#
|
6
|
+
# describe <%= class_name %>Helper do
|
7
|
+
# describe "string concat" do
|
8
|
+
# it "concats two strings with spaces" do
|
9
|
+
# expect(helper.concat_strings("this","that")).to eq("this that")
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
<% module_namespacing do -%>
|
14
|
+
RSpec.describe <%= class_name %>Helper, <%= type_metatag(:helper) %> do
|
15
|
+
pending "add some examples to (or delete) #{__FILE__}"
|
16
|
+
end
|
17
|
+
<% end -%>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "<%= class_name.pluralize %>", <%= type_metatag(:request) %> do
|
4
|
+
describe "GET /<%= table_name %>" do
|
5
|
+
it "works! (now write some real specs)" do
|
6
|
+
get <%= index_helper %>_path
|
7
|
+
expect(response).to have_http_status(200)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
<% module_namespacing do -%>
|
4
|
+
RSpec.describe <%= class_name %>, <%= type_metatag(:mailer) %> do
|
5
|
+
<% for action in actions -%>
|
6
|
+
describe "<%= action %>" do
|
7
|
+
let(:mail) { <%= class_name %>.<%= action %> }
|
8
|
+
|
9
|
+
it "renders the headers" do
|
10
|
+
expect(mail.subject).to eq(<%= action.to_s.humanize.inspect %>)
|
11
|
+
expect(mail.to).to eq(["to@example.org"])
|
12
|
+
expect(mail.from).to eq(["from@example.com"])
|
13
|
+
end
|
14
|
+
|
15
|
+
it "renders the body" do
|
16
|
+
expect(mail.body.encoded).to match("Hi")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
<% end -%>
|
21
|
+
<% if actions.blank? -%>
|
22
|
+
pending "add some examples to (or delete) #{__FILE__}"
|
23
|
+
<% end -%>
|
24
|
+
end
|
25
|
+
<% end -%>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<% module_namespacing do -%>
|
2
|
+
# Preview all emails at http://localhost:3000/rails/mailers/<%= file_path %>
|
3
|
+
class <%= class_name %>Preview < ActionMailer::Preview
|
4
|
+
<% actions.each do |action| -%>
|
5
|
+
|
6
|
+
# Preview this email at http://localhost:3000/rails/mailers/<%= file_path %>/<%= action %>
|
7
|
+
def <%= action %>
|
8
|
+
<%= class_name %>.<%= action %>
|
9
|
+
end
|
10
|
+
<% end -%>
|
11
|
+
|
12
|
+
end
|
13
|
+
<% end -%>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
2
|
+
|
3
|
+
<% unless attributes.empty? -%>
|
4
|
+
one:
|
5
|
+
<% for attribute in attributes -%>
|
6
|
+
<%= attribute.name %>: <%= attribute.default %>
|
7
|
+
<% end -%>
|
8
|
+
|
9
|
+
two:
|
10
|
+
<% for attribute in attributes -%>
|
11
|
+
<%= attribute.name %>: <%= attribute.default %>
|
12
|
+
<% end -%>
|
13
|
+
<% else -%>
|
14
|
+
# one:
|
15
|
+
# column: value
|
16
|
+
#
|
17
|
+
# two:
|
18
|
+
# column: value
|
19
|
+
<% end -%>
|
@@ -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) { {} }
|
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 -%>
|