voyage 1.44.0.4 → 1.44.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7cb3e8bad0a9367df50559e0cca52b41498543b3
4
- data.tar.gz: 566fcf34298cc07bb9c190aa706ca67ba79e5071
3
+ metadata.gz: 394ce85de666eddbe98828ebcced399f3c736d74
4
+ data.tar.gz: 39c3667979fba7d33f134d9e05f426f38bf53cb4
5
5
  SHA512:
6
- metadata.gz: c32afbce475a7abfb769b4f0820604d4dfe5337d2ec25e295f20373dea38aa798a8ff73462ee8d1ca9930a9592c7639c8f54ae626f924a347d5d2e42150d4995
7
- data.tar.gz: 887d5adfc95ace7511265fd8096bebb2b5bbd554a6358380627048d86a38659d494ddbde1de50073c71419f774f0b64e921267186e170fd03b80ec2b83257be0
6
+ metadata.gz: 68f4a19760d87f9e35370ed2f80f81b03d3bfc139c5fa57b1e8e618298a9f751f70b5acd12dd62e2869881e0cbdb01e3643f2fb0239d02a29f4a5918f241f71c
7
+ data.tar.gz: 115ab4812e477c7bd542d6e32b35a0bccfd79508b46ba98173b8f177d57254652c1008b600594a5187c3a9a53f7f2ec099576ffc721abe38a4d82035d409c6ce
@@ -126,6 +126,7 @@ module Suspenders
126
126
  add_sign_in_and_sign_out_routes_for_devise
127
127
  customize_user_factory(adding_first_and_last_name)
128
128
  generate_seeder_templates(using_devise: true)
129
+ customize_user_spec
129
130
  else
130
131
  generate_seeder_templates(using_devise: false)
131
132
  end
@@ -152,12 +153,13 @@ module Suspenders
152
153
  end
153
154
 
154
155
  def customize_application_controller_for_devise(adding_first_and_last_name)
155
- inject_into_file 'app/controllers/application_controller.rb', after: " protect_from_forgery with: :exception" do <<-RUBY.gsub(/^ {6}/, '').gsub(/^ {8}\n/, '')
156
- \n
156
+ inject_into_file 'app/controllers/application_controller.rb', after: " protect_from_forgery with: :exception" do <<-RUBY.gsub(/^ {6}/, '')
157
+
157
158
  before_action :configure_permitted_parameters, if: :devise_controller?
158
159
 
159
160
  protected
160
161
 
162
+ # rubocop:disable Metrics/MethodLength
161
163
  def configure_permitted_parameters
162
164
  devise_parameter_sanitizer.permit(
163
165
  :sign_up,
@@ -168,14 +170,14 @@ module Suspenders
168
170
  :password,
169
171
  :password_confirmation,
170
172
  :remember_me,
171
- ]
173
+ ],
172
174
  )
173
175
 
174
176
  devise_parameter_sanitizer.permit(
175
177
  :sign_in,
176
178
  keys: [
177
179
  :login, :email, :password, :remember_me
178
- ]
180
+ ],
179
181
  )
180
182
 
181
183
  devise_parameter_sanitizer.permit(
@@ -187,15 +189,17 @@ module Suspenders
187
189
  :password,
188
190
  :password_confirmation,
189
191
  :current_password,
190
- ]
192
+ ],
191
193
  )
192
194
  end
195
+ # rubocop:enable Metrics/MethodLength
193
196
  RUBY
194
197
  end
195
198
  end
196
199
 
197
200
  def customize_resource_controller_for_devise(adding_first_and_last_name)
198
- bundle_command "exec rails generate controller users"
201
+ bundle_command 'exec rails generate controller users'
202
+ run 'rm spec/controllers/users_controller_spec.rb'
199
203
 
200
204
  inject_into_class "app/controllers/users_controller.rb", "UsersController" do <<-RUBY.gsub(/^ {6}/, '')
201
205
  # https://github.com/CanCanCommunity/cancancan/wiki/authorizing-controller-actions
@@ -231,7 +235,7 @@ module Suspenders
231
235
 
232
236
  def add_canard_roles_to_devise_resource
233
237
  inject_into_file 'app/models/user.rb', before: /^end/ do <<-RUBY.gsub(/^ {6}/, '')
234
- \n
238
+
235
239
  # Permissions cascade/inherit through the roles listed below. The order of
236
240
  # this list is important, it should progress from least to most privelage
237
241
  ROLES = [:admin].freeze
@@ -294,6 +298,24 @@ module Suspenders
294
298
  template '../templates/seeds.rb.erb', 'db/seeds.rb', config
295
299
  end
296
300
 
301
+ def customize_user_spec
302
+ find = <<-RUBY.gsub(/^ {6}/, '')
303
+ pending "add some examples to (or delete) \#{__FILE__}"
304
+ RUBY
305
+
306
+ replace = <<-RUBY.gsub(/^ {6}/, '')
307
+ describe 'constants' do
308
+ context 'roles' do
309
+ it 'has the admin role' do
310
+ expect(User::ROLES).to eq([:admin])
311
+ end
312
+ end
313
+ end
314
+ RUBY
315
+
316
+ replace_in_file 'spec/models/user_spec.rb', find, replace
317
+ end
318
+
297
319
  def customize_application_js
298
320
  template '../templates/application.js', 'app/assets/javascripts/application.js', force: true
299
321
  end
@@ -362,6 +384,20 @@ module Suspenders
362
384
  run "erb2slim '../app/views/refills' '../app/views/refills'"
363
385
  run "erb2slim -d '../app/views/refills'"
364
386
  end
387
+
388
+ find = <<-RUBY.gsub(/^ {2}/, '')
389
+ | <div class="flash-
390
+ = key
391
+ | ">
392
+ = value
393
+ RUBY
394
+
395
+ replace = <<-RUBY.gsub(/^ {2}/, '')
396
+ div class="flash-\#{key}"
397
+ = value
398
+ RUBY
399
+
400
+ replace_in_file 'app/views/application/_flashes.html.slim', find, replace
365
401
  end
366
402
 
367
403
  def add_refills_to_layout
@@ -419,6 +455,10 @@ module Suspenders
419
455
  template '../templates/rubocop.yml', '.rubocop.yml', force: true
420
456
  end
421
457
 
458
+ def add_auto_annotate_models_rake_task
459
+ template '../templates/auto_annotate_models.rake', 'lib/tasks/auto_annotate_models.rake', force: true
460
+ end
461
+
422
462
  # Do this last
423
463
  def rake_db_setup
424
464
  rake 'db:migrate'
@@ -442,6 +482,24 @@ module Suspenders
442
482
  run 'mkdir -p .git/safe'
443
483
  end
444
484
 
485
+ def run_rubocop_auto_correct
486
+ run 'rubocop --auto-correct'
487
+ end
488
+
489
+ def copy_env_to_example
490
+ run 'cp .env .env.example'
491
+ end
492
+
493
+ def add_to_gitignore
494
+ inject_into_file '.gitignore', after: '/tmp/*' do <<-RUBY.gsub(/^ {8}/, '')
495
+
496
+ .env
497
+ .zenflow-log
498
+ errors.err
499
+ RUBY
500
+ end
501
+ end
502
+
445
503
  ###############################
446
504
  # OVERRIDE SUSPENDERS METHODS #
447
505
  ###############################
@@ -36,11 +36,15 @@ module Suspenders
36
36
  invoke :generate_test_environment
37
37
  invoke :update_test_environment
38
38
  invoke :add_rubocop_config
39
+ invoke :add_auto_annotate_models_rake_task
39
40
 
40
41
 
41
42
  # Do these last
42
43
  invoke :rake_db_setup
43
44
  invoke :configure_rvm_prepend_bin_to_path
45
+ invoke :run_rubocop_auto_correct
46
+ invoke :copy_env_to_example
47
+ invoke :add_to_gitignore
44
48
  invoke :actually_setup_spring
45
49
  invoke :bon_voyage
46
50
  super
@@ -98,6 +102,10 @@ module Suspenders
98
102
  build :add_rubocop_config
99
103
  end
100
104
 
105
+ def add_auto_annotate_models_rake_task
106
+ build :add_auto_annotate_models_rake_task
107
+ end
108
+
101
109
  def rake_db_setup
102
110
  build :rake_db_setup
103
111
  end
@@ -110,6 +118,18 @@ module Suspenders
110
118
  # do nothing so we can run generators after suspenders_customization runs
111
119
  end
112
120
 
121
+ def run_rubocop_auto_correct
122
+ build :run_rubocop_auto_correct
123
+ end
124
+
125
+ def copy_env_to_example
126
+ build :copy_env_to_example
127
+ end
128
+
129
+ def add_to_gitignore
130
+ build :add_to_gitignore
131
+ end
132
+
113
133
  def actually_setup_spring
114
134
  say "Springifying binstubs"
115
135
  build :setup_spring
@@ -0,0 +1,46 @@
1
+ # :nocov:
2
+ if Rails.env.development?
3
+ task :set_annotation_options do
4
+ # Just some example settings from annotate 2.6.0.beta1
5
+ Annotate.set_defaults(
6
+ 'position_in_routes' => 'after',
7
+ 'position_in_class' => 'after',
8
+ 'position_in_test' => 'after',
9
+ 'position_in_fixture' => 'after',
10
+ 'position_in_factory' => 'after',
11
+ 'show_indexes' => 'true',
12
+ 'simple_indexes' => 'false',
13
+ 'model_dir' => 'app/models',
14
+ 'include_version' => 'false',
15
+ 'require' => '',
16
+ 'exclude_tests' => 'false',
17
+ 'exclude_fixtures' => 'false',
18
+ 'exclude_factories' => 'false',
19
+ 'ignore_model_sub_dir' => 'false',
20
+ 'skip_on_db_migrate' => 'false',
21
+ 'format_bare' => 'true',
22
+ 'format_rdoc' => 'false',
23
+ 'format_markdown' => 'false',
24
+ 'sort' => 'true',
25
+ 'force' => 'false',
26
+ 'trace' => 'false',
27
+ )
28
+ end
29
+
30
+ # Annotate models
31
+ task :annotate do
32
+ puts 'Annotating models...'
33
+ system 'bundle exec annotate -p after -i'
34
+ end
35
+
36
+ # Run annotate task after db:migrate and db:rollback tasks
37
+ Rake::Task['db:migrate'].enhance do
38
+ Rake::Task['annotate'].invoke
39
+ Rake::Task['db:test:prepare'].invoke
40
+ end
41
+
42
+ Rake::Task['db:rollback'].enhance do
43
+ Rake::Task['annotate'].invoke
44
+ Rake::Task['db:test:prepare'].invoke
45
+ end
46
+ end
@@ -1,9 +1,9 @@
1
1
  module ControllerHelpers
2
- def sign_in(user = double('user'))
2
+ def sign_in(user = instance_double('user'))
3
3
  if user.nil?
4
4
  allow(request.env['warden'])
5
5
  .to receive(:authenticate!)
6
- .and_throw(:warden, { scope: :user })
6
+ .and_throw(:warden, scope: :user)
7
7
 
8
8
  allow(controller).to receive(:current_user).and_return(nil)
9
9
  else
@@ -1,3 +1,4 @@
1
+ # rubocop:disable Metrics/BlockLength
1
2
  rspec_module = defined?(RSpec::Core) ? 'RSpec' : 'Spec' # RSpec 1 compatability
2
3
 
3
4
  if rspec_module == 'RSpec'
@@ -24,8 +25,8 @@ Kernel.const_get(rspec_module)::Matchers.define :be_able_to do |*args|
24
25
 
25
26
  # Check that RSpec is < 2.99
26
27
  if !respond_to?(:failure_message) && respond_to?(:failure_message_for_should)
27
- alias :failure_message :failure_message_for_should
28
- alias :failure_message_when_negated :failure_message_for_should_not
28
+ alias_method :failure_message, :failure_message_for_should
29
+ alias_method :failure_message_when_negated, :failure_message_for_should_not
29
30
  end
30
31
 
31
32
  failure_message do
@@ -1,13 +1,14 @@
1
+ # rubocop:disable Metrics/BlockLength, Metrics/LineLength, Rails/FilePath
1
2
  require 'simplecov'
2
3
  SimpleCov.command_name 'Rspec'
3
4
 
4
- ENV["RACK_ENV"] = "test"
5
+ ENV['RACK_ENV'] = 'test'
5
6
 
6
- require File.expand_path("../../config/environment", __FILE__)
7
- abort("DATABASE_URL environment variable is set") if ENV["DATABASE_URL"]
7
+ require File.expand_path('../../config/environment', __FILE__)
8
+ abort('DATABASE_URL environment variable is set') if ENV['DATABASE_URL']
8
9
 
9
10
  require 'spec_helper'
10
- require "rspec/rails"
11
+ require 'rspec/rails'
11
12
  require 'factory_girl'
12
13
  require 'capybara/rspec'
13
14
  require 'capybara/poltergeist'
@@ -23,7 +24,7 @@ ActiveRecord::Migration.maintain_test_schema!
23
24
 
24
25
  # Requires supporting ruby files with custom matchers and macros, etc,
25
26
  # in spec/support/ and its subdirectories.
26
- Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |file| require file }
27
+ Dir[Rails.root.join('spec/support/**/*.rb')].sort.each { |file| require file }
27
28
 
28
29
  module Features
29
30
  # Extend this module in spec/support/features/*.rb
@@ -1,6 +1,8 @@
1
+ # rubocop:disable Rails/Output
1
2
  module Seeder
2
- extend self
3
- <% if config[:using_devise] %>
3
+ module_function
4
+
5
+ <% if config[:using_devise] -%>
4
6
  def admin_user
5
7
  puts '-----> Creating Admin User'
6
8
 
@@ -21,7 +23,7 @@ module Seeder
21
23
  create(:user, name.to_sym)
22
24
  end
23
25
  end
24
- <% else %>
26
+ <% else -%>
25
27
  # Change 'resource' to something real
26
28
  def seed_resource
27
29
  puts '-----> Creating Resource'
@@ -31,9 +33,10 @@ module Seeder
31
33
 
32
34
  create(:resource)
33
35
  end
34
- <% end %>
36
+ <% end -%>
35
37
  end
36
38
 
39
+ # rubocop:disable Metrics/LineLength
37
40
  if Rails.env == 'production'
38
41
  unless ENV['FORCE_SEED']
39
42
  puts
@@ -41,6 +44,7 @@ if Rails.env == 'production'
41
44
  puts 'WARNING: You are trying to run db:seed on production. This is a DESTRUCTIVE task.'
42
45
  puts 'If you know what you are doing, you can override by setting environment variable '
43
46
  puts 'FORCE_SEED=1'
44
- exit 1
47
+ abort('Exiting now...')
45
48
  end
46
49
  end
50
+ # rubocop:enable Rails/Output, Metrics/LineLength
@@ -1,4 +1,4 @@
1
- if ENV['COVERAGE'] =~ /\Atrue\z/i
1
+ if ENV['COVERAGE'].match?(/\Atrue\z/i)
2
2
  require 'cadre/simplecov'
3
3
 
4
4
  SimpleCov.start do
@@ -23,7 +23,7 @@ if ENV['COVERAGE'] =~ /\Atrue\z/i
23
23
 
24
24
  SimpleCov.formatters = [
25
25
  SimpleCov::Formatter::HTMLFormatter,
26
- Cadre::SimpleCov::VimFormatter
26
+ Cadre::SimpleCov::VimFormatter,
27
27
  ]
28
28
 
29
29
  SimpleCov.minimum_coverage 95
@@ -5,5 +5,5 @@ module Voyage
5
5
  .read("#{File.dirname(__FILE__)}/../../.ruby-version")
6
6
  .strip
7
7
  .freeze
8
- VERSION = '1.44.0.4'.freeze
8
+ VERSION = '1.44.0.5'.freeze
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voyage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.44.0.4
4
+ version: 1.44.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoughtbot, headway
@@ -109,6 +109,7 @@ files:
109
109
  - lib/voyage/templates/README.md.erb
110
110
  - lib/voyage/templates/about.html.erb
111
111
  - lib/voyage/templates/application.js
112
+ - lib/voyage/templates/auto_annotate_models.rake
112
113
  - lib/voyage/templates/config_locales_en.yml.erb
113
114
  - lib/voyage/templates/controller_helpers.rb
114
115
  - lib/voyage/templates/custom_cancan_matchers.rb