raygun 0.0.28 → 0.0.29
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -1
- data/CHANGES.md +7 -0
- data/README.md +3 -1
- data/bin/raygun +67 -44
- data/cleanup.sh +5 -0
- data/lib/colorize.rb +194 -0
- data/lib/raygun/version.rb +1 -1
- data/rails_32/.ruby-gemset +1 -0
- data/rails_32/Gemfile +1 -0
- data/rails_32/spec/spec_helper.rb +1 -17
- data/rails_32/spec/support/database_cleaner.rb +24 -0
- data/rails_40/.env +8 -0
- data/rails_40/.gitignore +16 -0
- data/rails_40/.rspec +1 -0
- data/rails_40/.ruby-gemset +1 -0
- data/rails_40/.ruby-version +1 -0
- data/rails_40/Gemfile +53 -0
- data/rails_40/Guardfile +32 -0
- data/rails_40/Procfile +2 -0
- data/rails_40/README.md +66 -0
- data/rails_40/Rakefile +15 -0
- data/rails_40/app/assets/javascripts/application.js +17 -0
- data/rails_40/app/assets/stylesheets/_footer.less +30 -0
- data/rails_40/app/assets/stylesheets/_navbar.less +5 -0
- data/rails_40/app/assets/stylesheets/application.css.less +3 -0
- data/rails_40/app/controllers/application_controller.rb +5 -0
- data/rails_40/app/controllers/concerns/.keep +0 -0
- data/rails_40/app/controllers/pages_controller.rb +6 -0
- data/rails_40/app/helpers/application_helper.rb +11 -0
- data/rails_40/app/mailers/.keep +0 -0
- data/rails_40/app/models/.keep +0 -0
- data/rails_40/app/models/concerns/.keep +0 -0
- data/rails_40/app/views/layouts/application.html.slim +36 -0
- data/rails_40/app/views/pages/root.html.slim +12 -0
- data/rails_40/bin/bundle +3 -0
- data/rails_40/bin/rails +4 -0
- data/rails_40/bin/rake +4 -0
- data/rails_40/config/application.rb +36 -0
- data/rails_40/config/boot.rb +4 -0
- data/rails_40/config/database.yml +15 -0
- data/rails_40/config/environment.rb +5 -0
- data/rails_40/config/environments/acceptance.rb +82 -0
- data/rails_40/config/environments/development.rb +31 -0
- data/rails_40/config/environments/production.rb +82 -0
- data/rails_40/config/environments/test.rb +38 -0
- data/rails_40/config/initializers/backtrace_silencers.rb +7 -0
- data/rails_40/config/initializers/filter_parameter_logging.rb +4 -0
- data/rails_40/config/initializers/inflections.rb +16 -0
- data/rails_40/config/initializers/mailcacher.rb +15 -0
- data/rails_40/config/initializers/mime_types.rb +5 -0
- data/rails_40/config/initializers/secret_token.rb +12 -0
- data/rails_40/config/initializers/session_store.rb +3 -0
- data/rails_40/config/initializers/simple_form.rb +142 -0
- data/rails_40/config/initializers/simple_form_bootstrap.rb +45 -0
- data/rails_40/config/initializers/wrap_parameters.rb +14 -0
- data/rails_40/config/locales/en.yml +23 -0
- data/rails_40/config/locales/simple_form.en.yml +26 -0
- data/rails_40/config/routes.rb +5 -0
- data/rails_40/config/unicorn.rb +27 -0
- data/rails_40/config.ru +18 -0
- data/rails_40/db/sample_data.rb +11 -0
- data/rails_40/db/schema.rb +19 -0
- data/rails_40/db/seeds.rb +7 -0
- data/rails_40/lib/assets/.keep +0 -0
- data/rails_40/lib/tasks/.keep +0 -0
- data/rails_40/lib/tasks/coverage.rake +10 -0
- data/rails_40/lib/tasks/db.rake +7 -0
- data/rails_40/lib/tasks/spec.rake +23 -0
- data/rails_40/lib/templates/rails/scaffold_controller/controller.rb +61 -0
- data/rails_40/lib/templates/rspec/controller/controller_spec.rb +16 -0
- data/rails_40/lib/templates/rspec/scaffold/controller_spec.rb +155 -0
- data/rails_40/lib/templates/rspec/scaffold/edit_spec.rb +18 -0
- data/rails_40/lib/templates/rspec/scaffold/index_spec.rb +26 -0
- data/rails_40/lib/templates/rspec/scaffold/new_spec.rb +19 -0
- data/rails_40/lib/templates/rspec/scaffold/show_spec.rb +16 -0
- data/rails_40/lib/templates/slim/scaffold/_form.html.slim +13 -0
- data/rails_40/lib/templates/slim/scaffold/edit.html.slim +5 -0
- data/rails_40/lib/templates/slim/scaffold/index.html.slim +29 -0
- data/rails_40/lib/templates/slim/scaffold/new.html.slim +4 -0
- data/rails_40/lib/templates/slim/scaffold/show.html.slim +17 -0
- data/rails_40/log/.keep +0 -0
- data/rails_40/public/404.html +58 -0
- data/rails_40/public/422.html +58 -0
- data/rails_40/public/500.html +57 -0
- data/rails_40/public/favicon.ico +0 -0
- data/rails_40/public/robots.txt +5 -0
- data/rails_40/spec/controllers/pages_controller_spec.rb +12 -0
- data/rails_40/spec/features/pages_spec.rb +18 -0
- data/rails_40/spec/spec_helper.rb +79 -0
- data/rails_40/spec/support/database_cleaner.rb +24 -0
- data/rails_40/spec/support/factory_girl.rb +3 -0
- data/rails_40/vendor/assets/javascripts/.keep +0 -0
- data/rails_40/vendor/assets/stylesheets/.keep +0 -0
- metadata +88 -6
- data/.rvmrc +0 -1
- data/app_prototype/config/routes.rb +0 -21
- data/app_prototype/db/schema.rb +0 -54
- data/rails_32/.rvmrc +0 -1
@@ -0,0 +1,142 @@
|
|
1
|
+
# Use this setup block to configure all options available in SimpleForm.
|
2
|
+
SimpleForm.setup do |config|
|
3
|
+
# Wrappers are used by the form builder to generate a
|
4
|
+
# complete input. You can remove any component from the
|
5
|
+
# wrapper, change the order or even add your own to the
|
6
|
+
# stack. The options given below are used to wrap the
|
7
|
+
# whole input.
|
8
|
+
config.wrappers :default, class: :input,
|
9
|
+
hint_class: :field_with_hint, error_class: :field_with_errors do |b|
|
10
|
+
## Extensions enabled by default
|
11
|
+
# Any of these extensions can be disabled for a
|
12
|
+
# given input by passing: `f.input EXTENSION_NAME => false`.
|
13
|
+
# You can make any of these extensions optional by
|
14
|
+
# renaming `b.use` to `b.optional`.
|
15
|
+
|
16
|
+
# Determines whether to use HTML5 (:email, :url, ...)
|
17
|
+
# and required attributes
|
18
|
+
b.use :html5
|
19
|
+
|
20
|
+
# Calculates placeholders automatically from I18n
|
21
|
+
# You can also pass a string as f.input placeholder: "Placeholder"
|
22
|
+
b.use :placeholder
|
23
|
+
|
24
|
+
## Optional extensions
|
25
|
+
# They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
|
26
|
+
# to the input. If so, they will retrieve the values from the model
|
27
|
+
# if any exists. If you want to enable the lookup for any of those
|
28
|
+
# extensions by default, you can change `b.optional` to `b.use`.
|
29
|
+
|
30
|
+
# Calculates maxlength from length validations for string inputs
|
31
|
+
b.optional :maxlength
|
32
|
+
|
33
|
+
# Calculates pattern from format validations for string inputs
|
34
|
+
b.optional :pattern
|
35
|
+
|
36
|
+
# Calculates min and max from length validations for numeric inputs
|
37
|
+
b.optional :min_max
|
38
|
+
|
39
|
+
# Calculates readonly automatically from readonly attributes
|
40
|
+
b.optional :readonly
|
41
|
+
|
42
|
+
## Inputs
|
43
|
+
b.use :label_input
|
44
|
+
b.use :hint, wrap_with: { tag: :span, class: :hint }
|
45
|
+
b.use :error, wrap_with: { tag: :span, class: :error }
|
46
|
+
end
|
47
|
+
|
48
|
+
# The default wrapper to be used by the FormBuilder.
|
49
|
+
config.default_wrapper = :default
|
50
|
+
|
51
|
+
# Define the way to render check boxes / radio buttons with labels.
|
52
|
+
# Defaults to :nested for bootstrap config.
|
53
|
+
# inline: input + label
|
54
|
+
# nested: label > input
|
55
|
+
config.boolean_style = :nested
|
56
|
+
|
57
|
+
# Default class for buttons
|
58
|
+
config.button_class = 'btn'
|
59
|
+
|
60
|
+
# Method used to tidy up errors. Specify any Rails Array method.
|
61
|
+
# :first lists the first message for each field.
|
62
|
+
# Use :to_sentence to list all errors for each field.
|
63
|
+
# config.error_method = :first
|
64
|
+
|
65
|
+
# Default tag used for error notification helper.
|
66
|
+
config.error_notification_tag = :div
|
67
|
+
|
68
|
+
# CSS class to add for error notification helper.
|
69
|
+
config.error_notification_class = 'alert alert-error'
|
70
|
+
|
71
|
+
# ID to add for error notification helper.
|
72
|
+
# config.error_notification_id = nil
|
73
|
+
|
74
|
+
# Series of attempts to detect a default label method for collection.
|
75
|
+
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
76
|
+
|
77
|
+
# Series of attempts to detect a default value method for collection.
|
78
|
+
# config.collection_value_methods = [ :id, :to_s ]
|
79
|
+
|
80
|
+
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
|
81
|
+
# config.collection_wrapper_tag = nil
|
82
|
+
|
83
|
+
# You can define the class to use on all collection wrappers. Defaulting to none.
|
84
|
+
# config.collection_wrapper_class = nil
|
85
|
+
|
86
|
+
# You can wrap each item in a collection of radio/check boxes with a tag,
|
87
|
+
# defaulting to :span. Please note that when using :boolean_style = :nested,
|
88
|
+
# SimpleForm will force this option to be a label.
|
89
|
+
# config.item_wrapper_tag = :span
|
90
|
+
|
91
|
+
# You can define a class to use in all item wrappers. Defaulting to none.
|
92
|
+
# config.item_wrapper_class = nil
|
93
|
+
|
94
|
+
# How the label text should be generated altogether with the required text.
|
95
|
+
config.label_text = lambda { |label, required| "#{label}" }
|
96
|
+
|
97
|
+
# You can define the class to use on all labels. Default is nil.
|
98
|
+
config.label_class = 'control-label'
|
99
|
+
|
100
|
+
# You can define the class to use on all forms. Default is simple_form.
|
101
|
+
# config.form_class = :simple_form
|
102
|
+
|
103
|
+
# You can define which elements should obtain additional classes
|
104
|
+
# config.generate_additional_classes_for = [:wrapper, :label, :input]
|
105
|
+
|
106
|
+
# Whether attributes are required by default (or not). Default is true.
|
107
|
+
# config.required_by_default = true
|
108
|
+
|
109
|
+
# Tell browsers whether to use the native HTML5 validations (novalidate form option).
|
110
|
+
# These validations are enabled in SimpleForm's internal config but disabled by default
|
111
|
+
# in this configuration, which is recommended due to some quirks from different browsers.
|
112
|
+
# To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
|
113
|
+
# change this configuration to true.
|
114
|
+
config.browser_validations = false
|
115
|
+
|
116
|
+
# Collection of methods to detect if a file type was given.
|
117
|
+
# config.file_methods = [ :mounted_as, :file?, :public_filename ]
|
118
|
+
|
119
|
+
# Custom mappings for input types. This should be a hash containing a regexp
|
120
|
+
# to match as key, and the input type that will be used when the field name
|
121
|
+
# matches the regexp as value.
|
122
|
+
# config.input_mappings = { /count/ => :integer }
|
123
|
+
|
124
|
+
# Custom wrappers for input types. This should be a hash containing an input
|
125
|
+
# type as key and the wrapper that will be used for all inputs with specified type.
|
126
|
+
# config.wrapper_mappings = { string: :prepend }
|
127
|
+
|
128
|
+
# Default priority for time_zone inputs.
|
129
|
+
# config.time_zone_priority = nil
|
130
|
+
|
131
|
+
# Default priority for country inputs.
|
132
|
+
# config.country_priority = nil
|
133
|
+
|
134
|
+
# When false, do not use translations for labels.
|
135
|
+
# config.translate_labels = true
|
136
|
+
|
137
|
+
# Automatically discover new inputs in Rails' autoload path.
|
138
|
+
# config.inputs_discovery = true
|
139
|
+
|
140
|
+
# Cache SimpleForm inputs discovery
|
141
|
+
# config.cache_discovery = !Rails.env.development?
|
142
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# Use this setup block to configure all options available in SimpleForm.
|
2
|
+
SimpleForm.setup do |config|
|
3
|
+
config.wrappers :bootstrap, tag: 'div', class: 'control-group', error_class: 'error' do |b|
|
4
|
+
b.use :html5
|
5
|
+
b.use :placeholder
|
6
|
+
b.use :label
|
7
|
+
b.wrapper tag: 'div', class: 'controls' do |ba|
|
8
|
+
ba.use :input
|
9
|
+
ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
|
10
|
+
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
config.wrappers :prepend, tag: 'div', class: "control-group", error_class: 'error' do |b|
|
15
|
+
b.use :html5
|
16
|
+
b.use :placeholder
|
17
|
+
b.use :label
|
18
|
+
b.wrapper tag: 'div', class: 'controls' do |input|
|
19
|
+
input.wrapper tag: 'div', class: 'input-prepend' do |prepend|
|
20
|
+
prepend.use :input
|
21
|
+
end
|
22
|
+
input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
|
23
|
+
input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
config.wrappers :append, tag: 'div', class: "control-group", error_class: 'error' do |b|
|
28
|
+
b.use :html5
|
29
|
+
b.use :placeholder
|
30
|
+
b.use :label
|
31
|
+
b.wrapper tag: 'div', class: 'controls' do |input|
|
32
|
+
input.wrapper tag: 'div', class: 'input-append' do |append|
|
33
|
+
append.use :input
|
34
|
+
end
|
35
|
+
input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
|
36
|
+
input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Wrappers for forms and inputs using the Twitter Bootstrap toolkit.
|
41
|
+
# Check the Bootstrap docs (http://twitter.github.com/bootstrap)
|
42
|
+
# to learn about the different styles for forms and inputs,
|
43
|
+
# buttons and other elements.
|
44
|
+
config.default_wrapper = :bootstrap
|
45
|
+
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,26 @@
|
|
1
|
+
en:
|
2
|
+
simple_form:
|
3
|
+
"yes": 'Yes'
|
4
|
+
"no": 'No'
|
5
|
+
required:
|
6
|
+
text: 'required'
|
7
|
+
mark: '*'
|
8
|
+
# You can uncomment the line below if you need to overwrite the whole required html.
|
9
|
+
# When using html, text and mark won't be used.
|
10
|
+
# html: '<abbr title="required">*</abbr>'
|
11
|
+
error_notification:
|
12
|
+
default_message: "Please review the problems below:"
|
13
|
+
# Labels and hints examples
|
14
|
+
# labels:
|
15
|
+
# defaults:
|
16
|
+
# password: 'Password'
|
17
|
+
# user:
|
18
|
+
# new:
|
19
|
+
# email: 'E-mail to sign in.'
|
20
|
+
# edit:
|
21
|
+
# email: 'E-mail.'
|
22
|
+
# hints:
|
23
|
+
# defaults:
|
24
|
+
# username: 'User name to sign in.'
|
25
|
+
# password: 'No special characters, please.'
|
26
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# http://unicorn.bogomips.org/
|
2
|
+
# https://blog.heroku.com/archives/2013/2/27/unicorn_rails
|
3
|
+
# http://devblog.thinkthroughmath.com/blog/2013/02/27/managing-request-queuing-with-rails-on-heroku/
|
4
|
+
|
5
|
+
listen ENV['PORT'], backlog: Integer(ENV['UNICORN_BACKLOG'] || 16)
|
6
|
+
worker_processes Integer(ENV['UNICORN_WORKERS'] || 3)
|
7
|
+
timeout 30
|
8
|
+
preload_app true
|
9
|
+
|
10
|
+
before_fork do |server, worker|
|
11
|
+
Signal.trap 'TERM' do
|
12
|
+
puts 'Unicorn master intercepting TERM and sending myself QUIT instead.'
|
13
|
+
Process.kill 'QUIT', Process.pid
|
14
|
+
end
|
15
|
+
|
16
|
+
defined?(ActiveRecord::Base) and
|
17
|
+
ActiveRecord::Base.connection.disconnect!
|
18
|
+
end
|
19
|
+
|
20
|
+
after_fork do |server, worker|
|
21
|
+
Signal.trap 'TERM' do
|
22
|
+
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT.'
|
23
|
+
end
|
24
|
+
|
25
|
+
defined?(ActiveRecord::Base) and
|
26
|
+
ActiveRecord::Base.establish_connection
|
27
|
+
end
|
data/rails_40/config.ru
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# This file is used by Rack-based servers to start the application.
|
2
|
+
|
3
|
+
require ::File.expand_path('../config/environment', __FILE__)
|
4
|
+
|
5
|
+
# Disable buffering for real time logging, see: https://devcenter.heroku.com/articles/logging#writing-to-your-log
|
6
|
+
$stdout.sync = true
|
7
|
+
|
8
|
+
# Optional Basic Auth - Enabled if BASIC_AUTH_PASSWORD is set. User is optional (any value will be accepted).
|
9
|
+
BASIC_AUTH_USER = ENV['BASIC_AUTH_USER']
|
10
|
+
BASIC_AUTH_PASSWORD = ENV['BASIC_AUTH_PASSWORD']
|
11
|
+
|
12
|
+
if BASIC_AUTH_PASSWORD
|
13
|
+
use Rack::Auth::Basic do |username, password|
|
14
|
+
password == BASIC_AUTH_PASSWORD && (BASIC_AUTH_USER.blank? || username == BASIC_AUTH_USER)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
run AppPrototype::Application
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Populate the database with a small set of realistic sample data so that as a developer/designer, you can use the
|
2
|
+
# application without having to create a bunch of stuff or pull down production data.
|
3
|
+
#
|
4
|
+
# After running db:sample_data, a developer/designer should be able to fire up the app, sign in, browse data and see
|
5
|
+
# examples of practically anything (interesting) that can happen in the system.
|
6
|
+
#
|
7
|
+
# It's a good idea to build this up along with the features; when you build a feature, make sure you can easily demo it
|
8
|
+
# after running db:sample_data.
|
9
|
+
#
|
10
|
+
# Data that is required by the application across all environments (i.e. reference data) should _not_ be included here.
|
11
|
+
# That belongs in seeds.rb instead.
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended that you check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(version: 0) do
|
15
|
+
|
16
|
+
# These are extensions that must be enabled in order to support this database
|
17
|
+
enable_extension "plpgsql"
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
7
|
+
# Mayor.create(name: 'Emanuel', city: cities.first)
|
File without changes
|
File without changes
|
@@ -0,0 +1,7 @@
|
|
1
|
+
namespace :db do
|
2
|
+
desc "Load a small, representative set of data so that the application can start in an use state (for development)."
|
3
|
+
task sample_data: :environment do
|
4
|
+
sample_data = File.join(Rails.root, 'db', 'sample_data.rb')
|
5
|
+
load(sample_data) if sample_data
|
6
|
+
end
|
7
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
begin
|
2
|
+
require 'rspec/core'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
namespace :spec do
|
6
|
+
desc "Run the code examples in spec/ except those in spec/features"
|
7
|
+
RSpec::Core::RakeTask.new('without_features' => 'db:test:prepare') do |t|
|
8
|
+
t.pattern = "./spec/[^features]**/**/*_spec.rb"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
rescue LoadError
|
13
|
+
namespace :spec do
|
14
|
+
task :without_requests do
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
Rake::Task['spec'].clear_actions
|
21
|
+
|
22
|
+
desc 'Runs all specs'
|
23
|
+
task spec: ['spec:without_features', 'spec:features']
|
@@ -0,0 +1,61 @@
|
|
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
|
+
before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy]
|
8
|
+
|
9
|
+
def index
|
10
|
+
@<%= plural_table_name %> = <%= orm_class.all(class_name) %>
|
11
|
+
end
|
12
|
+
|
13
|
+
def show
|
14
|
+
end
|
15
|
+
|
16
|
+
def new
|
17
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name) %>
|
18
|
+
end
|
19
|
+
|
20
|
+
def edit
|
21
|
+
end
|
22
|
+
|
23
|
+
def create
|
24
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>
|
25
|
+
|
26
|
+
if @<%= orm_instance.save %>
|
27
|
+
redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully created.'" %>
|
28
|
+
else
|
29
|
+
render action: 'new'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def update
|
34
|
+
if @<%= orm_instance.update("#{singular_table_name}_params") %>
|
35
|
+
redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully updated.'" %>
|
36
|
+
else
|
37
|
+
render action: 'edit'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def destroy
|
42
|
+
@<%= orm_instance.destroy %>
|
43
|
+
redirect_to <%= index_helper %>_url, notice: <%= "'#{human_name} was successfully destroyed.'" %>
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
# Use callbacks to share common setup or constraints between actions.
|
48
|
+
def set_<%= singular_table_name %>
|
49
|
+
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
50
|
+
end
|
51
|
+
|
52
|
+
# Only allow a trusted parameter "white list" through.
|
53
|
+
def <%= "#{singular_table_name}_params" %>
|
54
|
+
<%- if attributes_names.empty? -%>
|
55
|
+
params[<%= ":#{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 -%>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
<% module_namespacing do -%>
|
4
|
+
describe <%= class_name %>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 be_success
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
<% end -%>
|
15
|
+
end
|
16
|
+
<% end -%>
|
@@ -0,0 +1,155 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
<% module_namespacing do -%>
|
4
|
+
describe <%= controller_class_name %>Controller do
|
5
|
+
|
6
|
+
# This should return the minimal set of attributes required to create a valid
|
7
|
+
# <%= class_name %>. As you add validations to <%= class_name %>, be sure to
|
8
|
+
# update the return value of this method accordingly.
|
9
|
+
def valid_attributes
|
10
|
+
attributes_for :<%= file_name %>
|
11
|
+
end
|
12
|
+
|
13
|
+
# This should return the minimal set of values that should be in the session
|
14
|
+
# in order to pass any filters (e.g. authentication) defined in
|
15
|
+
# <%= controller_class_name %>Controller. Be sure to keep this updated too.
|
16
|
+
def valid_session
|
17
|
+
{}
|
18
|
+
end
|
19
|
+
|
20
|
+
before do
|
21
|
+
# TODO Set to :user and specify authorization rules in Ability.rb.
|
22
|
+
# login_user build :admin
|
23
|
+
end
|
24
|
+
|
25
|
+
<% unless options[:singleton] -%>
|
26
|
+
describe "#index" do
|
27
|
+
it "assigns all <%= table_name.pluralize %> as @<%= table_name.pluralize %>" do
|
28
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
29
|
+
get :index, {}, valid_session
|
30
|
+
expect(assigns(:<%= table_name %>)).to eq([<%= file_name %>])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
<% end -%>
|
35
|
+
describe "#show" do
|
36
|
+
it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
|
37
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
38
|
+
get :show, { :id => <%= file_name %>.to_param }, valid_session
|
39
|
+
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#new" do
|
44
|
+
it "assigns a new <%= ns_file_name %> as @<%= ns_file_name %>" do
|
45
|
+
get :new, {}, valid_session
|
46
|
+
expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#edit" do
|
51
|
+
it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
|
52
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
53
|
+
get :edit, { :id => <%= file_name %>.to_param }, valid_session
|
54
|
+
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#create" do
|
59
|
+
describe "with valid params" do
|
60
|
+
it "creates a new <%= class_name %>" do
|
61
|
+
expect {
|
62
|
+
post :create, { :<%= ns_file_name %> => valid_attributes }, valid_session
|
63
|
+
}.to change(<%= class_name %>, :count).by(1)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "assigns a newly created <%= ns_file_name %> as @<%= ns_file_name %>" do
|
67
|
+
post :create, {:<%= ns_file_name %> => valid_attributes }, valid_session
|
68
|
+
expect(assigns(:<%= ns_file_name %>)).to be_a(<%= class_name %>)
|
69
|
+
expect(assigns(:<%= ns_file_name %>)).to be_persisted
|
70
|
+
end
|
71
|
+
|
72
|
+
it "redirects to the created <%= ns_file_name %>" do
|
73
|
+
post :create, { :<%= ns_file_name %> => valid_attributes }, valid_session
|
74
|
+
expect(response).to redirect_to(<%= class_name %>.last)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "with invalid params" do
|
79
|
+
it "assigns a newly created but unsaved <%= ns_file_name %> as @<%= ns_file_name %>" do
|
80
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
81
|
+
<%= class_name %>.any_instance.stub(:save).and_return(false)
|
82
|
+
post :create, { :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %> }, valid_session
|
83
|
+
expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "re-renders the 'new' template" do
|
87
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
88
|
+
<%= class_name %>.any_instance.stub(:save).and_return(false)
|
89
|
+
post :create, { :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %> }, valid_session
|
90
|
+
expect(response).to render_template("new")
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "#update" do
|
96
|
+
describe "with valid params" do
|
97
|
+
it "updates the requested <%= ns_file_name %>" do
|
98
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
99
|
+
# Assuming there are no other <%= table_name %> in the database, this
|
100
|
+
# specifies that the <%= class_name %> created on the previous line
|
101
|
+
# receives the :update message with whatever params are submitted in
|
102
|
+
# the request.
|
103
|
+
<%= class_name %>.any_instance.should_receive(:update).with(<%= formatted_hash(example_params_for_update) %>)
|
104
|
+
put :update, { :id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_params_for_update) %> }, valid_session
|
105
|
+
end
|
106
|
+
|
107
|
+
it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
|
108
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
109
|
+
put :update, { :id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes }, valid_session
|
110
|
+
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "redirects to the <%= ns_file_name %>" do
|
114
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
115
|
+
put :update, { :id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes }, valid_session
|
116
|
+
expect(response).to redirect_to(<%= file_name %>)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "with invalid params" do
|
121
|
+
it "assigns the <%= ns_file_name %> as @<%= ns_file_name %>" do
|
122
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
123
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
124
|
+
<%= class_name %>.any_instance.stub(:save).and_return(false)
|
125
|
+
put :update, { :id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %> }, valid_session
|
126
|
+
expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
|
127
|
+
end
|
128
|
+
|
129
|
+
it "re-renders the 'edit' template" do
|
130
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
131
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
132
|
+
<%= class_name %>.any_instance.stub(:save).and_return(false)
|
133
|
+
put :update, { :id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %> }, valid_session
|
134
|
+
expect(response).to render_template("edit")
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe "#destroy" do
|
140
|
+
it "destroys the requested <%= ns_file_name %>" do
|
141
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
142
|
+
expect {
|
143
|
+
delete :destroy, { :id => <%= file_name %>.to_param }, valid_session
|
144
|
+
}.to change(<%= class_name %>, :count).by(-1)
|
145
|
+
end
|
146
|
+
|
147
|
+
it "redirects to the <%= table_name %> list" do
|
148
|
+
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
149
|
+
delete :destroy, { :id => <%= file_name %>.to_param }, valid_session
|
150
|
+
expect(response).to redirect_to(<%= index_helper %>_url)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
<% end -%>
|
@@ -0,0 +1,18 @@
|
|
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
|
+
before(:each) do
|
6
|
+
@<%= ns_file_name %> = assign(:<%= ns_file_name %>, build_stubbed(:<%= class_name.underscore %>))
|
7
|
+
end
|
8
|
+
|
9
|
+
it "renders the edit <%= ns_file_name %> form" do
|
10
|
+
render
|
11
|
+
|
12
|
+
assert_select "form", action: <%= index_helper %>_path(@<%= ns_file_name %>), method: "post" do
|
13
|
+
<% for attribute in output_attributes -%>
|
14
|
+
assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", name: "<%= ns_file_name %>[<%= attribute.name %>]"
|
15
|
+
<% end -%>
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|