workbook_rails 0.1.1 → 0.2.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.
Files changed (60) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +12 -7
  3. data/Gemfile.lock +251 -179
  4. data/README.md +24 -30
  5. data/Rakefile +6 -15
  6. data/lib/tasks/workbook_rails_tasks.rake +2 -0
  7. data/lib/workbook_rails/action_controller.rb +20 -18
  8. data/lib/workbook_rails/engine.rb +8 -8
  9. data/lib/workbook_rails/template_handler.rb +9 -7
  10. data/lib/workbook_rails/version.rb +3 -1
  11. data/lib/workbook_rails.rb +3 -2
  12. data/spec/ci.rb +5 -1
  13. data/spec/dummy/Rakefile +3 -1
  14. data/spec/dummy/app/assets/config/manifest.js +3 -0
  15. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  16. data/spec/dummy/app/controllers/home_controller.rb +14 -20
  17. data/spec/dummy/app/controllers/likes_controller.rb +3 -1
  18. data/spec/dummy/app/controllers/users_controller.rb +4 -2
  19. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  20. data/spec/dummy/app/mailers/notifier.rb +6 -5
  21. data/spec/dummy/app/models/like.rb +2 -0
  22. data/spec/dummy/app/models/user.rb +2 -0
  23. data/spec/dummy/bin/bundle +3 -1
  24. data/spec/dummy/bin/rails +3 -1
  25. data/spec/dummy/bin/rake +2 -0
  26. data/spec/dummy/config/application.rb +9 -8
  27. data/spec/dummy/config/boot.rb +4 -2
  28. data/spec/dummy/config/environment.rb +3 -1
  29. data/spec/dummy/config/environments/development.rb +2 -0
  30. data/spec/dummy/config/environments/production.rb +2 -0
  31. data/spec/dummy/config/environments/test.rb +6 -4
  32. data/spec/dummy/config/initializers/backtrace_silencers.rb +2 -0
  33. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -1
  34. data/spec/dummy/config/initializers/filter_parameter_logging.rb +2 -0
  35. data/spec/dummy/config/initializers/inflections.rb +2 -0
  36. data/spec/dummy/config/initializers/mime_types.rb +2 -0
  37. data/spec/dummy/config/initializers/secret_token.rb +3 -1
  38. data/spec/dummy/config/initializers/session_store.rb +2 -0
  39. data/spec/dummy/config/initializers/wrap_parameters.rb +2 -0
  40. data/spec/dummy/config/routes.rb +13 -12
  41. data/spec/dummy/config.ru +3 -1
  42. data/spec/dummy/db/migrate/20120717192452_create_users.rb +3 -1
  43. data/spec/dummy/db/migrate/20121206210955_create_likes.rb +3 -1
  44. data/spec/dummy/db/schema.rb +19 -22
  45. data/spec/dummy/db/test.sqlite3 +0 -0
  46. data/spec/dummy/log/test.log +7332 -8068
  47. data/spec/spec_helper.rb +19 -12
  48. data/spec/template_handler_spec.rb +13 -16
  49. data/spec/test_7.2.sh +6 -0
  50. data/spec/test_8.0.sh +6 -0
  51. data/spec/test_8.1.sh +6 -0
  52. data/spec/test_all_rails.sh +10 -4
  53. data/spec/workbook_mailer_spec.rb +9 -4
  54. data/spec/workbook_renderer_spec.rb +22 -16
  55. data/spec/workbook_request_spec.rb +78 -77
  56. metadata +26 -142
  57. data/spec/test_3.2.sh +0 -4
  58. data/spec/test_4.0.sh +0 -4
  59. data/spec/test_4.1.sh +0 -4
  60. data/spec/test_4.2.sh +0 -4
data/Rakefile CHANGED
@@ -1,16 +1,9 @@
1
1
  #!/usr/bin/env rake
2
- begin
3
- require 'bundler/setup'
4
- rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
- end
7
- begin
8
- require 'rdoc/task'
9
- rescue LoadError
10
- require 'rdoc/rdoc'
11
- require 'rake/rdoctask'
12
- RDoc::Task = Rake::RDocTask
13
- end
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'rdoc/task'
6
+ require 'rspec/core/rake_task'
14
7
 
15
8
  RDoc::Task.new(:rdoc) do |rdoc|
16
9
  rdoc.rdoc_dir = 'rdoc'
@@ -20,10 +13,8 @@ RDoc::Task.new(:rdoc) do |rdoc|
20
13
  rdoc.rdoc_files.include('lib/**/*.rb')
21
14
  end
22
15
 
23
- require "rspec/core/rake_task"
24
16
  RSpec::Core::RakeTask.new('spec')
25
17
 
26
- task :default => :spec
18
+ task default: :spec
27
19
 
28
20
  Bundler::GemHelper.install_tasks
29
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # desc "Explaining what the task does"
2
4
  # task :workbook_rails do
3
5
  # # Task goes here
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #
2
4
  # You can always specify a template:
3
5
  #
@@ -15,37 +17,37 @@
15
17
  #
16
18
  WorkbookRails::FORMATS.each do |format|
17
19
  ActionController::Renderers.add format do |filename, options|
18
- if options[:template] == action_name
19
- options[:template] = filename.gsub(/^.*\//,'')
20
+ if options[:template].nil? || options[:template] == action_name
21
+ options[:template] = filename.gsub(%r{^.*/}, '')
22
+ options[:prefixes] ||= [controller_path]
20
23
  end
21
24
 
22
25
  # disposition / filename
23
26
  disposition = options.delete(:disposition) || 'attachment'
24
- if file_name = options.delete(:filename)
27
+ if (file_name = options.delete(:filename))
25
28
  file_name += ".#{format}" unless file_name =~ /\.#{format}$/
26
29
  else
27
- file_name = "#{filename.gsub(/^.*\//,'')}.#{format}"
30
+ file_name = "#{filename.gsub(%r{^.*/}, '')}.#{format}"
28
31
  end
29
32
 
30
- options = options.merge(:formats => [format])
31
- send_data render_to_string(options), :filename => file_name, :type => Mime::Type.lookup_by_extension(format), :disposition => disposition
33
+ options = options.merge(layout: false)
34
+ send_data render_to_string(options), filename: file_name, type: Mime[format], disposition: disposition
32
35
  end
33
36
  end
34
37
 
35
38
  # For respond_to default
36
- begin
37
- ActionController::Responder
38
- rescue
39
- else
40
- class ActionController::Responder
41
- WorkbookRails::FORMATS.each do |format|
42
- define_method "to_#{format}" do
43
- if @default_response
44
- @default_response.call(options)
45
- else
46
- controller.render options.reverse_merge(format => controller.action_name)
39
+ if ActionController.const_defined? 'Responder'
40
+ module ActionController
41
+ class Responder
42
+ WorkbookRails::FORMATS.each do |format|
43
+ define_method "to_#{format}" do
44
+ if @default_response
45
+ @default_response.call(options)
46
+ else
47
+ controller.render options.reverse_merge(format => controller.action_name)
48
+ end
47
49
  end
48
50
  end
49
51
  end
50
52
  end
51
- end
53
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'workbook'
2
4
  require 'workbook_rails/template_handler'
3
5
 
@@ -12,14 +14,12 @@ module WorkbookRails
12
14
  initializer 'workbook_rails.action_controller' do
13
15
  ActiveSupport.on_load :action_controller do
14
16
  require 'workbook_rails/action_controller'
15
- end
16
- end
17
17
 
18
- unless Mime::Type.lookup_by_extension(:xlsx)
19
- Mime::Type.register "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", :xlsx
20
- end
21
- unless Mime::Type.lookup_by_extension(:xls)
22
- Mime::Type.register "application/vnd.ms-excel", :xls
18
+ unless Mime[:xlsx]
19
+ Mime::Type.register 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', :xlsx
20
+ end
21
+ Mime::Type.register 'application/vnd.ms-excel', :xls unless Mime[:xls]
22
+ end
23
23
  end
24
24
  end
25
- end
25
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WorkbookRails
2
4
  class TemplateHandler
3
5
  class_attribute :default_format
@@ -7,18 +9,18 @@ module WorkbookRails
7
9
  case format
8
10
  when :csv then workbook.sheet.table.to_csv
9
11
  when :xlsx then workbook.stream_xlsx
10
- when :xls then
12
+ when :xls
11
13
  io = StringIO.new
12
- workbook.to_xls.write(io)
14
+ xls = workbook.is_a?(Spreadsheet::Workbook) ? workbook : workbook.to_xls
15
+ xls.write(io)
13
16
  io.string
14
17
  end
15
18
  end
16
19
 
17
- def self.call(template)
18
- "workbook = Workbook::Book.new;\n" +
19
- template.source +
20
- ";\nWorkbookRails::TemplateHandler.workbook_to_string(workbook, lookup_context.rendered_format);"
20
+ def self.call(template, source = nil)
21
+ "workbook = Workbook::Book.new;\n" \
22
+ "#{source || template.source};\n" \
23
+ 'WorkbookRails::TemplateHandler.workbook_to_string(workbook, lookup_context.formats.last);'
21
24
  end
22
-
23
25
  end
24
26
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WorkbookRails
2
- VERSION = "0.1.1"
4
+ VERSION = '0.2.1'
3
5
  end
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'workbook_rails/engine'
2
4
  module WorkbookRails
3
- FORMATS = [:xlsx, :xls, :csv]
5
+ FORMATS = %i[xlsx xls csv].freeze
4
6
  end
5
-
data/spec/ci.rb CHANGED
@@ -1,3 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- exit system('cd spec/dummy && bundle install --without debug && bundle exec rake db:create && bundle exec rake db:migrate && cd ../../ && bundle exec rspec spec')
4
+ exit system(
5
+ 'cd spec/dummy && bundle install && bundle exec rake db:create && ' \
6
+ 'bundle exec rake db:migrate && cd ../../ && bundle exec rspec spec'
7
+ )
data/spec/dummy/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Add your own tasks in files placed in lib/tasks ending in .rake,
2
4
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
5
 
4
- require File.expand_path('../config/application', __FILE__)
6
+ require File.expand_path('config/application', __dir__)
5
7
 
6
8
  Rails.application.load_tasks
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ApplicationController < ActionController::Base
2
4
  # Prevent CSRF attacks by raising an exception.
3
5
  # For APIs, you may want to use :null_session instead.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #---
2
4
  # Excerpted from "Crafting Rails Applications",
3
5
  # published by The Pragmatic Bookshelf.
@@ -7,8 +9,7 @@
7
9
  # Visit http://www.pragmaticprogrammer.com/titles/jvrails for more book information.
8
10
  #---
9
11
  class HomeController < ApplicationController
10
- def index
11
- end
12
+ def index; end
12
13
 
13
14
  def generic
14
15
  respond_to do |format|
@@ -22,40 +23,33 @@ class HomeController < ApplicationController
22
23
  def only_html; end
23
24
 
24
25
  def another
25
- render :xlsx => "index", :filename => "filename_test.xlsx"
26
+ render xlsx: 'index', filename: 'filename_test.xlsx'
26
27
  end
27
28
 
28
29
  def render_elsewhere
29
30
  case params[:type]
30
- when '1'
31
- render :xlsx => "home/index", :template => 'users/respond_with'
32
- when '2'
33
- render :xlsx => "users/respond_with", :template => 'users/respond_with'
31
+ when '1', '2'
32
+ render xlsx: params[:type] == '1' ? 'home/index' : 'users/respond_with', template: 'users/respond_with'
34
33
  when '3'
35
- render template: "users/respond_with"
34
+ render template: 'users/respond_with'
36
35
  when '4'
37
- render "users/respond_with"
36
+ render 'users/respond_with'
38
37
  else
39
- render :xlsx => "index"
38
+ render xlsx: 'index'
40
39
  end
41
40
  end
42
41
 
43
- def render_file_path
44
- render :xlsx => 'index', :file => Rails.root.join('app','views','users','respond_with')
45
- end
46
-
47
- def withpartial
48
- end
42
+ def withpartial; end
49
43
 
50
44
  def useheader
51
45
  respond_to do |format|
52
- format.xlsx {
46
+ format.xlsx do
53
47
  if params[:set_direct]
54
- response.headers['Content-Disposition'] = "attachment; filename=\"filename_test.xlsx\""
48
+ response.headers['Content-Disposition'] = 'attachment; filename="filename_test.xlsx"'
55
49
  else
56
- render xlsx: "useheader", filename: "filename_test.xlsx"
50
+ render xlsx: 'useheader', filename: 'filename_test.xlsx'
57
51
  end
58
- }
52
+ end
59
53
  end
60
54
  end
61
55
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class LikesController < ApplicationController
2
4
  # GET /likes
3
5
  # GET /likes.json
@@ -13,6 +15,6 @@ class LikesController < ApplicationController
13
15
 
14
16
  def render_elsewhere
15
17
  @user = User.find(params[:user_id])
16
- render :xlsx => "index", :template => 'users/respond_with'
18
+ render xlsx: 'index', template: 'users/respond_with'
17
19
  end
18
20
  end
@@ -1,16 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class UsersController < ApplicationController
2
4
  respond_to :xlsx, :html
3
5
 
4
6
  def show
5
7
  @user = User.find(params[:id])
6
8
  respond_with(@user) do |format|
7
- format.xlsx { render "respond_with" }
9
+ format.xlsx { render 'respond_with' }
8
10
  end
9
11
  end
10
12
 
11
13
  def send_instructions
12
14
  @user = User.find(params[:user_id])
13
15
  @user.send_instructions
14
- render text: "Email sent"
16
+ render plain: 'Email sent'
15
17
  end
16
18
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ApplicationHelper
2
4
  end
@@ -1,14 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Notifier < ActionMailer::Base
2
- default :from => 'noreply@company.com'
4
+ default from: 'noreply@company.com'
3
5
 
4
6
  def instructions(user)
5
7
  @user = user
6
8
 
7
9
  # normal syntax
8
10
  xlsx = render_to_string handlers: [:wb], template: 'users/mailers/instructions', layout: false, formats: [:xlsx]
9
- attachments["user_#{user.id}.xlsx"] = {mime_type: Mime::XLSX, content: xlsx}
11
+ attachments["user_#{user.id}.xlsx"] = { mime_type: Mime[:xlsx], content: xlsx }
10
12
 
11
- mail :to => user.email, :subject => 'Instructions'
13
+ mail to: user.email, subject: 'Instructions'
12
14
  end
13
-
14
- end
15
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Like < ActiveRecord::Base
2
4
  belongs_to :user
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class User < ActiveRecord::Base
2
4
  has_many :likes
3
5
 
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2
+ # frozen_string_literal: true
3
+
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3
5
  load Gem.bin_path('bundler', 'bundle')
data/spec/dummy/bin/rails CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
2
+ # frozen_string_literal: true
3
+
4
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
5
  require_relative '../config/boot'
4
6
  require 'rails/commands'
data/spec/dummy/bin/rake CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  require_relative '../config/boot'
3
5
  require 'rake'
4
6
  Rake.application.run
@@ -1,20 +1,22 @@
1
- require File.expand_path('../boot', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('boot', __dir__)
2
4
 
3
5
  require 'rails/version'
4
6
  if Rails::VERSION::MAJOR < 4
5
7
  # Pick the frameworks you want:
6
- require "active_record/railtie"
7
- require "action_controller/railtie"
8
- require "action_mailer/railtie"
9
- require "active_resource/railtie"
10
- require "sprockets/railtie"
8
+ require 'active_record/railtie'
9
+ require 'action_controller/railtie'
10
+ require 'action_mailer/railtie'
11
+ require 'active_resource/railtie'
12
+ require 'sprockets/railtie'
11
13
  # require "rails/test_unit/railtie"
12
14
  else
13
15
  require 'rails/all'
14
16
  end
15
17
 
16
18
  Bundler.require(*Rails.groups)
17
- require "workbook_rails"
19
+ require 'workbook_rails'
18
20
 
19
21
  module Dummy
20
22
  class Application < Rails::Application
@@ -31,4 +33,3 @@ module Dummy
31
33
  # config.i18n.default_locale = :de
32
34
  end
33
35
  end
34
-
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Set up gems listed in the Gemfile.
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
3
5
 
4
6
  require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
7
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Load the Rails application.
2
- require File.expand_path('../application', __FILE__)
4
+ require File.expand_path('application', __dir__)
3
5
 
4
6
  # Initialize the Rails application.
5
7
  Rails.application.initialize!
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
@@ -1,4 +1,6 @@
1
- #Rails.application.configure do
1
+ # frozen_string_literal: true
2
+
3
+ # Rails.application.configure do
2
4
  Dummy::Application.configure do
3
5
  # Settings specified here will take precedence over those in config/application.rb.
4
6
 
@@ -15,9 +17,9 @@ Dummy::Application.configure do
15
17
 
16
18
  # Configure static asset server for tests with Cache-Control for performance.
17
19
  if config.respond_to? :serve_static_files
18
- config.serve_static_files = true
20
+ config.serve_static_files = true
19
21
  else
20
- config.serve_static_assets = true
22
+ config.serve_static_assets = true
21
23
  end
22
24
  config.static_cache_control = 'public, max-age=3600'
23
25
 
@@ -26,7 +28,7 @@ Dummy::Application.configure do
26
28
  config.action_controller.perform_caching = false
27
29
 
28
30
  # Raise exceptions instead of rendering exception templates.
29
- config.action_dispatch.show_exceptions = false
31
+ config.action_dispatch.show_exceptions = :none
30
32
 
31
33
  # Disable request forgery protection in test environment.
32
34
  config.action_controller.allow_forgery_protection = false
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
- Rails.application.config.action_dispatch.cookies_serializer = :json
5
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Configure sensitive parameters which will be filtered from the log file.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Add new inflection rules using the following format. Inflections
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Add new mime types for use in respond_to blocks:
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Dummy::Application.config.secret_token = 'afaaa2094c84c6a6082e6d8752d42984'
2
- Dummy::Application.config.secret_key_base = 'new secret key base'
4
+ Dummy::Application.config.secret_key_base = 'new secret key base'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  Rails.application.config.session_store :cookie_store, key: '_dummy_session'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # This file contains settings for ActionController::ParamsWrapper which
@@ -1,17 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.routes.draw do
2
- get "/users/:user_id/render_elsewhere(.:format)", :to => "likes#render_elsewhere"
3
- get "/users/:user_id/send_instructions", :to => "users#send_instructions"
4
+ get '/users/:user_id/render_elsewhere(.:format)', to: 'likes#render_elsewhere'
5
+ get '/users/:user_id/send_instructions', to: 'users#send_instructions'
4
6
  resources :users do
5
7
  resources :likes
6
8
  end
7
- get "/home(.:format)", :to => "home#index", :as => :home
8
- get "/home/generic(.:format)", :to => "home#generic", :as => :generic
9
- get "/home/only_html", :to => "home#only_html", :as => :only_html
10
- get "/another(.:format)", :to => "home#another", :as => :another
11
- get "/useheader(.:format)", :to => "home#useheader", :as => :useheader
12
- get "/withpartial(.:format)", :to => "home#withpartial", :as => :withpartial
13
- get "/home/render_elsewhere(.:format)", :to => "home#render_elsewhere"
14
- get "/render_elsewhere(.:format)", :to => "home#render_elsewhere"
15
- get "/render_file_path(.:format)", :to => "home#render_file_path"
16
- root to: "home#index"
9
+ get '/home(.:format)', to: 'home#index', as: :home
10
+ get '/home/generic(.:format)', to: 'home#generic', as: :generic
11
+ get '/home/only_html', to: 'home#only_html', as: :only_html
12
+ get '/another(.:format)', to: 'home#another', as: :another
13
+ get '/useheader(.:format)', to: 'home#useheader', as: :useheader
14
+ get '/withpartial(.:format)', to: 'home#withpartial', as: :withpartial
15
+ get '/home/render_elsewhere(.:format)', to: 'home#render_elsewhere'
16
+ get '/render_elsewhere(.:format)', to: 'home#render_elsewhere'
17
+ root to: 'home#index'
17
18
  end
data/spec/dummy/config.ru CHANGED
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is used by Rack-based servers to start the application.
2
4
 
3
- require ::File.expand_path('../config/environment', __FILE__)
5
+ require ::File.expand_path('config/environment', __dir__)
4
6
  run Rails.application
@@ -1,4 +1,6 @@
1
- class CreateUsers < ActiveRecord::Migration
1
+ # frozen_string_literal: true
2
+
3
+ class CreateUsers < (Rails.version < '5.1' ? ActiveRecord::Migration : ActiveRecord::Migration[5.0])
2
4
  def change
3
5
  create_table :users do |t|
4
6
  t.string :name
@@ -1,4 +1,6 @@
1
- class CreateLikes < ActiveRecord::Migration
1
+ # frozen_string_literal: true
2
+
3
+ class CreateLikes < (Rails.version < '5.1' ? ActiveRecord::Migration : ActiveRecord::Migration[5.0])
2
4
  def change
3
5
  create_table :likes do |t|
4
6
  t.string :name