diff --git a/.travis.yml b/.travis.yml index 1ca7100..91d72c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,8 @@ env: - RAILS_VERSION=4.2 - RAILS_VERSION=5.0 - RAILS_VERSION=5.1 - # - RAILS_VERSION=5.2 + - RAILS_VERSION=5.2 + - RAILS_VERSION=6.0 rvm: - 2.2.10 - 2.3.7 diff --git a/CHANGELOG.md b/CHANGELOG.md index 051a508..9a74d8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change log +**September 5, 2019**: 0.5.3 release + +- Improved Rails 6.0 compatibility re MIME type + **May 1st, 2018**: 0.5.2 release - Improved Rails 5 compatibility re MIME type @@ -75,7 +79,7 @@ **July 17, 2012**: 0.1.0 release - Tests completed -- Acts_as_xlsx tested, example in docs +- Acts_as_xlsx tested, example in docs **July 12, 2012**: 0.0.1 release diff --git a/Gemfile b/Gemfile index ce12c57..64dbf16 100644 --- a/Gemfile +++ b/Gemfile @@ -5,9 +5,12 @@ source "http://rubygems.org" # development dependencies will be added by default to the :development group. gemspec -ENV["RAILS_VERSION"] ||= '4.2' +ENV["RAILS_VERSION"] ||= '6.0' case ENV['RAILS_VERSION'] +when '6.0' + gem 'rails', "~> 6" + gem 'responders', '~> 2.0' when '5.1' gem 'rails', "~> 5.1.0" gem 'responders', '~> 2.0' diff --git a/lib/axlsx_rails/template_handler.rb b/lib/axlsx_rails/template_handler.rb index f2c9983..0a60f4f 100644 --- a/lib/axlsx_rails/template_handler.rb +++ b/lib/axlsx_rails/template_handler.rb @@ -8,7 +8,14 @@ module Template::Handlers class AxlsxBuilder def default_format - Rails.version.to_f >= 5 ? Mime[:xlsx] : Mime::XLSX + case + when Rails.version.to_f >= 6 + Mime[:xlsx].symbol + when Rails.version.to_f >= 5 + Mime[:xlsx] + else + Mime::XLSX + end end def call(template, source = nil) diff --git a/lib/axlsx_rails/version.rb b/lib/axlsx_rails/version.rb index ee3718d..3e225ad 100644 --- a/lib/axlsx_rails/version.rb +++ b/lib/axlsx_rails/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module AxlsxRails - VERSION = '0.5.2' + VERSION = '0.5.3' end diff --git a/spec/ci.rb b/spec/ci.rb index dce984f..adeb238 100755 --- a/spec/ci.rb +++ b/spec/ci.rb @@ -1,6 +1,9 @@ #!/usr/bin/env ruby -if ENV['RAILS_VERSION'] =~ /^5.2/ +if ENV['RAILS_VERSION'] =~ /^6.0/ + puts "Testing Rails 6.0" + exit system('cd spec/dummy_6.0 && bundle install --without debug && bundle exec rake db:create && bundle exec rake db:migrate && cd ../../ && bundle exec rspec spec') +elsif ENV['RAILS_VERSION'] =~ /^5.2/ puts "Testing Rails 5.2" exit system('cd spec/dummy_5.2 && bundle install --without debug && bundle exec rake db:create && bundle exec rake db:migrate && cd ../../ && bundle exec rspec spec') elsif ENV['RAILS_VERSION'] =~ /^5.1/ diff --git a/spec/dummy_6.0/Rakefile b/spec/dummy_6.0/Rakefile new file mode 100644 index 0000000..ba6b733 --- /dev/null +++ b/spec/dummy_6.0/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +Rails.application.load_tasks diff --git a/spec/dummy_6.0/app/assets/images/.keep b/spec/dummy_6.0/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/dummy_6.0/app/assets/javascripts/application.js b/spec/dummy_6.0/app/assets/javascripts/application.js new file mode 100644 index 0000000..5bc2e1c --- /dev/null +++ b/spec/dummy_6.0/app/assets/javascripts/application.js @@ -0,0 +1,13 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require_tree . diff --git a/spec/dummy_6.0/app/assets/stylesheets/application.css b/spec/dummy_6.0/app/assets/stylesheets/application.css new file mode 100644 index 0000000..a443db3 --- /dev/null +++ b/spec/dummy_6.0/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/spec/dummy_6.0/app/controllers/application_controller.rb b/spec/dummy_6.0/app/controllers/application_controller.rb new file mode 100644 index 0000000..d83690e --- /dev/null +++ b/spec/dummy_6.0/app/controllers/application_controller.rb @@ -0,0 +1,5 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception +end diff --git a/spec/dummy_6.0/app/controllers/concerns/.keep b/spec/dummy_6.0/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/dummy_6.0/app/controllers/home_controller.rb b/spec/dummy_6.0/app/controllers/home_controller.rb new file mode 100644 index 0000000..c1c35f9 --- /dev/null +++ b/spec/dummy_6.0/app/controllers/home_controller.rb @@ -0,0 +1,56 @@ +#--- +# Excerpted from "Crafting Rails Applications", +# published by The Pragmatic Bookshelf. +# Copyrights apply to this code. It may not be used to create training material, +# courses, books, articles, and the like. Contact us if you are in doubt. +# We make no guarantees that this code is fit for any purpose. +# Visit http://www.pragmaticprogrammer.com/titles/jvrails for more book information. +#--- +class HomeController < ApplicationController + def index + respond_to do |format| + format.html + format.xlsx + end + end + + def only_html; end + + def another + render :xlsx => "index", :filename => "filename_test.xlsx" + end + + def render_elsewhere + case params[:type] + when '1' + render :xlsx => "home/index", :template => 'users/index' + when '2' + render :xlsx => "users/index", :template => 'users/index' + when '3' + render template: "users/index" + when '4' + render "users/index" + else + render :xlsx => "index" + end + end + + def render_file_path + render :xlsx => Rails.root.join('app','views','users','index') + end + + def withpartial + end + + def useheader + respond_to do |format| + format.xlsx { + if params[:set_direct] + response.headers['Content-Disposition'] = "attachment; filename=\"filename_test.xlsx\"" + else + render xlsx: "useheader", filename: "filename_test.xlsx" + end + } + end + end +end diff --git a/spec/dummy_6.0/app/controllers/likes_controller.rb b/spec/dummy_6.0/app/controllers/likes_controller.rb new file mode 100644 index 0000000..9b48bca --- /dev/null +++ b/spec/dummy_6.0/app/controllers/likes_controller.rb @@ -0,0 +1,18 @@ +class LikesController < ApplicationController + # GET /likes + # GET /likes.json + def index + @user = User.find(params[:user_id]) + @likes = @user.likes + + respond_to do |format| + format.html # index.html.erb + format.xlsx + end + end + + def render_elsewhere + @user = User.find(params[:user_id]) + render :xlsx => "index", :template => 'users/index' + end +end diff --git a/spec/dummy_6.0/app/controllers/users_controller.rb b/spec/dummy_6.0/app/controllers/users_controller.rb new file mode 100644 index 0000000..2905010 --- /dev/null +++ b/spec/dummy_6.0/app/controllers/users_controller.rb @@ -0,0 +1,37 @@ +class UsersController < ApplicationController + respond_to :xlsx, :html + layout Proc.new { |c| return (c.request.format.symbol == :xlsx ? false : :default )} + + # GET /users + # GET /users.json + def index + @users = User.all + + respond_to do |format| + format.html # index.html.erb + format.xlsx + end + end + + def show + @user = User.find(params[:id]) + respond_with(@user) do |format| + format.xlsx { render "respond_with.xlsx.axlsx" } + end + end + + def send_instructions + @user = User.find(params[:user_id]) + @user.send_instructions + render plain: "Email sent" + end + + def export + @user = User.find(params[:id]) + respond_to do |format| + format.xlsx do + render xlsx: "export", filename: "export_#{@user.id}" + end + end + end +end diff --git a/spec/dummy_6.0/app/helpers/application_helper.rb b/spec/dummy_6.0/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/spec/dummy_6.0/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/spec/dummy_6.0/app/mailers/.keep b/spec/dummy_6.0/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/dummy_6.0/app/mailers/notifier.rb b/spec/dummy_6.0/app/mailers/notifier.rb new file mode 100644 index 0000000..269fdb5 --- /dev/null +++ b/spec/dummy_6.0/app/mailers/notifier.rb @@ -0,0 +1,14 @@ +class Notifier < ActionMailer::Base + default :from => 'noreply@company.com' + + def instructions(user) + @user = user + + # normal syntax + xlsx = render_to_string handlers: [:axlsx], template: 'users/send_instructions', layout: false, formats: [:xlsx] + attachments["user_#{user.id}.xlsx"] = {mime_type: Mime[:xlsx], content: xlsx} + + mail :to => user.email, :subject => 'Instructions' + end + +end \ No newline at end of file diff --git a/spec/dummy_6.0/app/models/.keep b/spec/dummy_6.0/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/dummy_6.0/app/models/concerns/.keep b/spec/dummy_6.0/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/dummy_6.0/app/models/like.rb b/spec/dummy_6.0/app/models/like.rb new file mode 100644 index 0000000..f7dc2c7 --- /dev/null +++ b/spec/dummy_6.0/app/models/like.rb @@ -0,0 +1,3 @@ +class Like < ActiveRecord::Base + belongs_to :user +end diff --git a/spec/dummy_6.0/app/models/user.rb b/spec/dummy_6.0/app/models/user.rb new file mode 100644 index 0000000..4b15e85 --- /dev/null +++ b/spec/dummy_6.0/app/models/user.rb @@ -0,0 +1,10 @@ +require 'acts_as_xlsx' +class User < ActiveRecord::Base + acts_as_xlsx columns: [:id, :name, :last_name, :address, :email] + + has_many :likes + + def send_instructions + Notifier.instructions(self).deliver + end +end diff --git a/spec/dummy_6.0/app/views/home/_cover_sheet.xlsx.axlsx b/spec/dummy_6.0/app/views/home/_cover_sheet.xlsx.axlsx new file mode 100644 index 0000000..cbe22d4 --- /dev/null +++ b/spec/dummy_6.0/app/views/home/_cover_sheet.xlsx.axlsx @@ -0,0 +1,3 @@ +wb.add_worksheet(name: "Cover Sheet") do |sheet| + sheet.add_row ['Cover', 'Sheet'] +end \ No newline at end of file diff --git a/spec/dummy_6.0/app/views/home/index.html.erb b/spec/dummy_6.0/app/views/home/index.html.erb new file mode 100644 index 0000000..fb0c3e0 --- /dev/null +++ b/spec/dummy_6.0/app/views/home/index.html.erb @@ -0,0 +1,4 @@ +

Hey, you can download the xlsx for this page by clicking the link below:

+

<%= link_to "XLSX", home_path("xlsx") %>

+

<%= link_to "Another", '/another.xlsx' %>

+

<%= link_to "User header", '/useheader.xlsx' %>

diff --git a/spec/dummy_6.0/app/views/home/index.xlsx.axlsx b/spec/dummy_6.0/app/views/home/index.xlsx.axlsx new file mode 100644 index 0000000..2598e86 --- /dev/null +++ b/spec/dummy_6.0/app/views/home/index.xlsx.axlsx @@ -0,0 +1,8 @@ +wb = xlsx_package.workbook +style_shout = wb.styles.add_style sz: 16, b: true, alignment: { horizontal: :center } +wb.add_worksheet(name: "Foobar") do |sheet| + sheet.add_row ['Bad', 'spellers', 'of', 'the', 'world', '...'] + sheet.add_row ['Untie!'] + sheet.merge_cells("A2:E2") + sheet["A2"].style = style_shout +end \ No newline at end of file diff --git a/spec/dummy_6.0/app/views/home/only_html.html.erb b/spec/dummy_6.0/app/views/home/only_html.html.erb new file mode 100644 index 0000000..8015221 --- /dev/null +++ b/spec/dummy_6.0/app/views/home/only_html.html.erb @@ -0,0 +1 @@ +

Foo, bar

diff --git a/spec/dummy_6.0/app/views/home/useheader.xlsx.axlsx b/spec/dummy_6.0/app/views/home/useheader.xlsx.axlsx new file mode 100644 index 0000000..2598e86 --- /dev/null +++ b/spec/dummy_6.0/app/views/home/useheader.xlsx.axlsx @@ -0,0 +1,8 @@ +wb = xlsx_package.workbook +style_shout = wb.styles.add_style sz: 16, b: true, alignment: { horizontal: :center } +wb.add_worksheet(name: "Foobar") do |sheet| + sheet.add_row ['Bad', 'spellers', 'of', 'the', 'world', '...'] + sheet.add_row ['Untie!'] + sheet.merge_cells("A2:E2") + sheet["A2"].style = style_shout +end \ No newline at end of file diff --git a/spec/dummy_6.0/app/views/home/withpartial.xlsx.axlsx b/spec/dummy_6.0/app/views/home/withpartial.xlsx.axlsx new file mode 100644 index 0000000..3d9109d --- /dev/null +++ b/spec/dummy_6.0/app/views/home/withpartial.xlsx.axlsx @@ -0,0 +1,9 @@ +wb = xlsx_package.workbook +render :partial => 'cover_sheet', :locals => {:wb => wb} +style_shout = wb.styles.add_style sz: 16, b: true, alignment: { horizontal: :center } +wb.add_worksheet(name: "Foobar") do |sheet| + sheet.add_row ['Bad', 'spellers', 'of', 'the', 'world', '...'] + sheet.add_row ['Untie!'] + sheet.merge_cells("A2:E2") + sheet["A2"].style = style_shout +end \ No newline at end of file diff --git a/spec/dummy_6.0/app/views/layouts/application.html.erb b/spec/dummy_6.0/app/views/layouts/application.html.erb new file mode 100644 index 0000000..f5ae581 --- /dev/null +++ b/spec/dummy_6.0/app/views/layouts/application.html.erb @@ -0,0 +1,12 @@ + + + + Dummy 6 + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/spec/dummy_6.0/app/views/layouts/users.html.erb b/spec/dummy_6.0/app/views/layouts/users.html.erb new file mode 100644 index 0000000..f5ae581 --- /dev/null +++ b/spec/dummy_6.0/app/views/layouts/users.html.erb @@ -0,0 +1,12 @@ + + + + Dummy 6 + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/spec/dummy_6.0/app/views/likes/index.html.erb b/spec/dummy_6.0/app/views/likes/index.html.erb new file mode 100644 index 0000000..5e2b8dc --- /dev/null +++ b/spec/dummy_6.0/app/views/likes/index.html.erb @@ -0,0 +1,17 @@ +

Listing likes for <%= @user.name %>

+ + + + + + +<% @likes.each do |like| %> + + + +<% end %> +
Name
<%= like.name %>
+ +
+ +<%= link_to 'New Like', new_like_path %> diff --git a/spec/dummy_6.0/app/views/likes/index.xlsx.axlsx b/spec/dummy_6.0/app/views/likes/index.xlsx.axlsx new file mode 100644 index 0000000..50b170f --- /dev/null +++ b/spec/dummy_6.0/app/views/likes/index.xlsx.axlsx @@ -0,0 +1,7 @@ +wb = xlsx_package.workbook +wb.add_worksheet(name: "Foobar") do |sheet| + sheet.add_row [@user.name] + @likes.each do |like| + sheet.add_row [like.name] + end +end \ No newline at end of file diff --git a/spec/dummy_6.0/app/views/notifier/instructions.html.erb b/spec/dummy_6.0/app/views/notifier/instructions.html.erb new file mode 100644 index 0000000..44f0800 --- /dev/null +++ b/spec/dummy_6.0/app/views/notifier/instructions.html.erb @@ -0,0 +1,14 @@ + + + + + + +

Instructions

+

+ You have successfully signed up to example.com, + your username is: <%= @user.email %>.
+

+

Thanks for joining and have a great day!

+ + diff --git a/spec/dummy_6.0/app/views/notifier/instructions.txt.erb b/spec/dummy_6.0/app/views/notifier/instructions.txt.erb new file mode 100644 index 0000000..eef493e --- /dev/null +++ b/spec/dummy_6.0/app/views/notifier/instructions.txt.erb @@ -0,0 +1,6 @@ +Instructions + +You have successfully signed up to example.com, +your username is: <%= @user.email %>. + +Thanks for joining and have a great day! diff --git a/spec/dummy_6.0/app/views/users/export.xlsx.axlsx b/spec/dummy_6.0/app/views/users/export.xlsx.axlsx new file mode 100644 index 0000000..2598e86 --- /dev/null +++ b/spec/dummy_6.0/app/views/users/export.xlsx.axlsx @@ -0,0 +1,8 @@ +wb = xlsx_package.workbook +style_shout = wb.styles.add_style sz: 16, b: true, alignment: { horizontal: :center } +wb.add_worksheet(name: "Foobar") do |sheet| + sheet.add_row ['Bad', 'spellers', 'of', 'the', 'world', '...'] + sheet.add_row ['Untie!'] + sheet.merge_cells("A2:E2") + sheet["A2"].style = style_shout +end \ No newline at end of file diff --git a/spec/dummy_6.0/app/views/users/index.html.erb b/spec/dummy_6.0/app/views/users/index.html.erb new file mode 100644 index 0000000..d38b48a --- /dev/null +++ b/spec/dummy_6.0/app/views/users/index.html.erb @@ -0,0 +1,23 @@ +

Listing users

+ + + + + + + + + +<% @users.each do |user| %> + + + + + + +<% end %> +
NameLast nameAddressEmail
<%= user.name %><%= user.last_name %><%= user.address %><%= user.email %>
+ +
+ +<%= link_to 'New User', new_user_path %> diff --git a/spec/dummy_6.0/app/views/users/index.xlsx.axlsx b/spec/dummy_6.0/app/views/users/index.xlsx.axlsx new file mode 100644 index 0000000..2b944bd --- /dev/null +++ b/spec/dummy_6.0/app/views/users/index.xlsx.axlsx @@ -0,0 +1 @@ +User.to_xlsx package: xlsx_package diff --git a/spec/dummy_6.0/app/views/users/noaction.xlsx.axlsx b/spec/dummy_6.0/app/views/users/noaction.xlsx.axlsx new file mode 100644 index 0000000..2b944bd --- /dev/null +++ b/spec/dummy_6.0/app/views/users/noaction.xlsx.axlsx @@ -0,0 +1 @@ +User.to_xlsx package: xlsx_package diff --git a/spec/dummy_6.0/app/views/users/respond_with.xlsx.axlsx b/spec/dummy_6.0/app/views/users/respond_with.xlsx.axlsx new file mode 100644 index 0000000..2598e86 --- /dev/null +++ b/spec/dummy_6.0/app/views/users/respond_with.xlsx.axlsx @@ -0,0 +1,8 @@ +wb = xlsx_package.workbook +style_shout = wb.styles.add_style sz: 16, b: true, alignment: { horizontal: :center } +wb.add_worksheet(name: "Foobar") do |sheet| + sheet.add_row ['Bad', 'spellers', 'of', 'the', 'world', '...'] + sheet.add_row ['Untie!'] + sheet.merge_cells("A2:E2") + sheet["A2"].style = style_shout +end \ No newline at end of file diff --git a/spec/dummy_6.0/app/views/users/send_instructions.xlsx.axlsx b/spec/dummy_6.0/app/views/users/send_instructions.xlsx.axlsx new file mode 100644 index 0000000..21a8a24 --- /dev/null +++ b/spec/dummy_6.0/app/views/users/send_instructions.xlsx.axlsx @@ -0,0 +1,5 @@ +wb = xlsx_package.workbook +wb.add_worksheet(name: "Instructions") do |sheet| + sheet.add_row [@user.id, @user.name, @user.email] + sheet.add_row ['', 'Instructions', ''] +end diff --git a/spec/dummy_6.0/bin/bundle b/spec/dummy_6.0/bin/bundle new file mode 100755 index 0000000..66e9889 --- /dev/null +++ b/spec/dummy_6.0/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/spec/dummy_6.0/bin/rails b/spec/dummy_6.0/bin/rails new file mode 100755 index 0000000..728cd85 --- /dev/null +++ b/spec/dummy_6.0/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/spec/dummy_6.0/bin/rake b/spec/dummy_6.0/bin/rake new file mode 100755 index 0000000..1724048 --- /dev/null +++ b/spec/dummy_6.0/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/spec/dummy_6.0/config.ru b/spec/dummy_6.0/config.ru new file mode 100644 index 0000000..5bc2a61 --- /dev/null +++ b/spec/dummy_6.0/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Rails.application diff --git a/spec/dummy_6.0/config/application.rb b/spec/dummy_6.0/config/application.rb new file mode 100644 index 0000000..2832baf --- /dev/null +++ b/spec/dummy_6.0/config/application.rb @@ -0,0 +1,23 @@ +require File.expand_path('../boot', __FILE__) + +require 'rails/all' + +Bundler.require(*Rails.groups) +require "axlsx_rails" + +module Dummy + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + end +end + diff --git a/spec/dummy_6.0/config/boot.rb b/spec/dummy_6.0/config/boot.rb new file mode 100644 index 0000000..6266cfc --- /dev/null +++ b/spec/dummy_6.0/config/boot.rb @@ -0,0 +1,5 @@ +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__) diff --git a/spec/dummy_6.0/config/database.yml b/spec/dummy_6.0/config/database.yml new file mode 100644 index 0000000..1c1a37c --- /dev/null +++ b/spec/dummy_6.0/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: 5 + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/spec/dummy_6.0/config/environment.rb b/spec/dummy_6.0/config/environment.rb new file mode 100644 index 0000000..ee8d90d --- /dev/null +++ b/spec/dummy_6.0/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require File.expand_path('../application', __FILE__) + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/spec/dummy_6.0/config/environments/development.rb b/spec/dummy_6.0/config/environments/development.rb new file mode 100644 index 0000000..ddf0e90 --- /dev/null +++ b/spec/dummy_6.0/config/environments/development.rb @@ -0,0 +1,37 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/spec/dummy_6.0/config/environments/production.rb b/spec/dummy_6.0/config/environments/production.rb new file mode 100644 index 0000000..47d3553 --- /dev/null +++ b/spec/dummy_6.0/config/environments/production.rb @@ -0,0 +1,83 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_assets = false + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # Version of your assets, change this if you want to expire all your assets. + config.assets.version = '1.0' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Set to :debug to see everything in the log. + config.log_level = :info + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets. + # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. + # config.assets.precompile += %w( search.js ) + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/spec/dummy_6.0/config/environments/test.rb b/spec/dummy_6.0/config/environments/test.rb new file mode 100644 index 0000000..7b2011f --- /dev/null +++ b/spec/dummy_6.0/config/environments/test.rb @@ -0,0 +1,40 @@ +#Rails.application.configure do +Dummy::Application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_assets = true + # config.static_cache_control = 'public, max-age=3600' + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/spec/dummy_6.0/config/initializers/backtrace_silencers.rb b/spec/dummy_6.0/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/spec/dummy_6.0/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/spec/dummy_6.0/config/initializers/cookies_serializer.rb b/spec/dummy_6.0/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..7a06a89 --- /dev/null +++ b/spec/dummy_6.0/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json \ No newline at end of file diff --git a/spec/dummy_6.0/config/initializers/filter_parameter_logging.rb b/spec/dummy_6.0/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/spec/dummy_6.0/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/spec/dummy_6.0/config/initializers/inflections.rb b/spec/dummy_6.0/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/spec/dummy_6.0/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/spec/dummy_6.0/config/initializers/mime_types.rb b/spec/dummy_6.0/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/spec/dummy_6.0/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/spec/dummy_6.0/config/initializers/secret_token.rb b/spec/dummy_6.0/config/initializers/secret_token.rb new file mode 100644 index 0000000..70d99c5 --- /dev/null +++ b/spec/dummy_6.0/config/initializers/secret_token.rb @@ -0,0 +1,2 @@ +Dummy::Application.config.secret_token = 'existing secret token' +Dummy::Application.config.secret_key_base = 'new secret key base' \ No newline at end of file diff --git a/spec/dummy_6.0/config/initializers/session_store.rb b/spec/dummy_6.0/config/initializers/session_store.rb new file mode 100644 index 0000000..e766b67 --- /dev/null +++ b/spec/dummy_6.0/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_dummy_session' diff --git a/spec/dummy_6.0/config/initializers/wrap_parameters.rb b/spec/dummy_6.0/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..33725e9 --- /dev/null +++ b/spec/dummy_6.0/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/spec/dummy_6.0/config/locales/en.yml b/spec/dummy_6.0/config/locales/en.yml new file mode 100644 index 0000000..0653957 --- /dev/null +++ b/spec/dummy_6.0/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/spec/dummy_6.0/config/routes.rb b/spec/dummy_6.0/config/routes.rb new file mode 100644 index 0000000..49601dd --- /dev/null +++ b/spec/dummy_6.0/config/routes.rb @@ -0,0 +1,17 @@ +Rails.application.routes.draw do + get "/users/:user_id/render_elsewhere(.:format)", :to => "likes#render_elsewhere" + get "/users/:user_id/send_instructions", :to => "users#send_instructions" + get "/users/noaction", :to => "users#noaction" + get "/users/export/:id", :to => "users#export" + resources :users do + resources :likes + end + get "/home(.:format)", :to => "home#index", :as => :home + get "/home/only_html", :to => "home#only_html", :as => :only_html + get "/another(.:format)", :to => "home#another", :as => :another + get "/useheader(.:format)", :to => "home#useheader", :as => :useheader + get "/withpartial(.:format)", :to => "home#withpartial", :as => :withpartial + get "/home/render_elsewhere(.:format)", :to => "home#render_elsewhere" + get "/render_elsewhere(.:format)", :to => "home#render_elsewhere" + root to: "home#index" +end diff --git a/spec/dummy_6.0/config/secrets.yml b/spec/dummy_6.0/config/secrets.yml new file mode 100644 index 0000000..27edc21 --- /dev/null +++ b/spec/dummy_6.0/config/secrets.yml @@ -0,0 +1,22 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: a379dda69862a8411c21a5657a822201520044ba6afc4eb650247079c545c6c566fa4119b818744c36d7faca4533542695e382a787ef9899a52754b4dcc4145c + +test: + secret_key_base: be4cce38d09d5ef8d251576c17b633e28d36efd34843b2a0930bc9450e7bfc1dbad6600e2a0f1f901b4f26c43dd916732966d1428c1f8eeb1218765856e5d84a + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/spec/dummy_6.0/db/migrate/20120717192452_create_users.rb b/spec/dummy_6.0/db/migrate/20120717192452_create_users.rb new file mode 100644 index 0000000..0df1924 --- /dev/null +++ b/spec/dummy_6.0/db/migrate/20120717192452_create_users.rb @@ -0,0 +1,12 @@ +class CreateUsers < ActiveRecord::Migration[6.0] + def change + create_table :users do |t| + t.string :name + t.string :last_name + t.string :address + t.string :email + + t.timestamps + end + end +end diff --git a/spec/dummy_6.0/db/migrate/20121206210955_create_likes.rb b/spec/dummy_6.0/db/migrate/20121206210955_create_likes.rb new file mode 100644 index 0000000..24c8796 --- /dev/null +++ b/spec/dummy_6.0/db/migrate/20121206210955_create_likes.rb @@ -0,0 +1,10 @@ +class CreateLikes < ActiveRecord::Migration[6.0] + def change + create_table :likes do |t| + t.string :name + t.integer :user_id + + t.timestamps + end + end +end diff --git a/spec/dummy_6.0/db/schema.rb b/spec/dummy_6.0/db/schema.rb new file mode 100644 index 0000000..bf5e3e7 --- /dev/null +++ b/spec/dummy_6.0/db/schema.rb @@ -0,0 +1,31 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 20121206210955) do + + create_table "likes", force: :cascade do |t| + t.string "name" + t.integer "user_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "users", force: :cascade do |t| + t.string "name" + t.string "last_name" + t.string "address" + t.string "email" + t.datetime "created_at" + t.datetime "updated_at" + end + +end diff --git a/spec/dummy_6.0/lib/assets/.keep b/spec/dummy_6.0/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/dummy_6.0/log/.keep b/spec/dummy_6.0/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/dummy_6.0/public/404.html b/spec/dummy_6.0/public/404.html new file mode 100644 index 0000000..b612547 --- /dev/null +++ b/spec/dummy_6.0/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/spec/dummy_6.0/public/422.html b/spec/dummy_6.0/public/422.html new file mode 100644 index 0000000..a21f82b --- /dev/null +++ b/spec/dummy_6.0/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/spec/dummy_6.0/public/500.html b/spec/dummy_6.0/public/500.html new file mode 100644 index 0000000..061abc5 --- /dev/null +++ b/spec/dummy_6.0/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/spec/dummy_6.0/public/favicon.ico b/spec/dummy_6.0/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c660f69..7017bbc 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,7 +3,10 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] = 'test' -if ENV['RAILS_VERSION'] =~ /^5.2/ +if ENV['RAILS_VERSION'] =~ /^6.0/ + puts "Testing Rails 6.0" + require File.expand_path("../dummy_6.0/config/environment", __FILE__) +elsif ENV['RAILS_VERSION'] =~ /^5.2/ puts "Testing Rails 5.2" require File.expand_path("../dummy_5.2/config/environment", __FILE__) elsif ENV['RAILS_VERSION'] =~ /^5.1/ diff --git a/spec/test_6.0.sh b/spec/test_6.0.sh new file mode 100644 index 0000000..1416cb4 --- /dev/null +++ b/spec/test_6.0.sh @@ -0,0 +1,16 @@ +export RAILS_ENV=test + +for version in 6.0 +do + echo "Testing Rails version " $version + rm Gemfile.lock + if [ -f Gemfile.lock.$version ]; + then + echo Reusing Gemfile.lock.$version + cp Gemfile.lock.$version Gemfile.lock + fi + rm spec/dummy_6.0/db/test.sqlite3 + export RAILS_VERSION=$version + spec/ci.rb + cp Gemfile.lock Gemfile.lock.$version +done diff --git a/spec/test_all_rails.sh b/spec/test_all_rails.sh index 77a2378..0fa6fac 100755 --- a/spec/test_all_rails.sh +++ b/spec/test_all_rails.sh @@ -1,6 +1,7 @@ spec/test_3.1.sh spec/test_3.2.sh spec/test_4.0.sh +spec/test_6.0.sh cp Gemfile.lock.orig Gemfile.lock bundle install