Skip to content

Commit

Permalink
Merge pull request #260 from schneems/schneems/test-rails6
Browse files Browse the repository at this point in the history
Schneems/test rails6
  • Loading branch information
schneems committed Nov 5, 2019
2 parents 6503a00 + 8f9d302 commit aa47805
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 158 deletions.
34 changes: 13 additions & 21 deletions .travis.yml
@@ -1,28 +1,20 @@
language: ruby
rvm:
- 1.9.3
- 2.0.0
- 2.1.1
- 2.2.2
- ruby-head
- jruby-19mode
- 2.3.0
- 2.4.0
- 2.5.0
- 2.6.0

sudo: false

gemfile:
- gemfiles/3.1.gemfile
- gemfiles/3.2.gemfile
- gemfiles/4.0.gemfile
- gemfiles/4.1.gemfile
- gemfiles/4.2.gemfile
matrix:
include:
- gemfile: gemfiles/5.0.beta2.gemfile
rvm: 2.2.2
allow_failures:
- gemfile: gemfiles/3.0.gemfile
rvm: 2.0.0
- gemfile: gemfiles/3.0.gemfile
rvm: 2.1.1
- rvm: ruby-head
- gemfiles/rails_5.1.gemfile
- gemfiles/rails_5.2.gemfile
- gemfiles/rails_6.0.1.gemfile

jobs:
exclude:
- gemfile: gemfiles/rails_6.0.1.gemfile
rvm: 2.3.0
- gemfile: gemfiles/rails_6.0.1.gemfile
rvm: 2.4.0
31 changes: 6 additions & 25 deletions Appraisals
@@ -1,30 +1,11 @@
appraise "3.1" do
gem "rails", "~> 3.1.0"
gemspec
appraise "rails-5.1" do
gem "rails", "~> 5.2"
end

appraise "3.2" do
gem "rails", "~> 3.2.15"
gemspec
appraise "rails-5.2" do
gem "rails", "~> 5.2"
end

appraise "4.0" do
gem "rails", "~> 4.0.0"
gemspec
end

appraise "4.1" do
gem "rails", "~> 4.1.0"
gemspec
end


appraise "4.2" do
gem "rails", "~> 4.2"
gemspec
end

appraise "5.0.beta2" do
gem "rails", "~> 5.0.0.beta2"
gemspec
appraise "rails-6.0.1" do
gem "rails", "~> 6.0.1"
end
6 changes: 1 addition & 5 deletions Gemfile
@@ -1,10 +1,6 @@
source "https://rubygems.org"


# Put all runtime dependencies in wicked.gemspec
# Put development requirements for different platforms here
# Put more specific gem declarations in different gemfiles/*.gemfile files
gemspec :path => ::File.expand_path("../.", __FILE__)
gemspec

group :development, :test do
gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
Expand Down
12 changes: 0 additions & 12 deletions gemfiles/3.1.gemfile

This file was deleted.

12 changes: 0 additions & 12 deletions gemfiles/3.2.gemfile

This file was deleted.

12 changes: 0 additions & 12 deletions gemfiles/4.0.gemfile

This file was deleted.

12 changes: 0 additions & 12 deletions gemfiles/4.1.gemfile

This file was deleted.

12 changes: 0 additions & 12 deletions gemfiles/4.2.gemfile

This file was deleted.

12 changes: 0 additions & 12 deletions gemfiles/5.0.beta2.gemfile

This file was deleted.

12 changes: 12 additions & 0 deletions gemfiles/rails_5.1.gemfile
@@ -0,0 +1,12 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 5.2"

group :development, :test do
gem "sqlite3", platform: [:ruby, :mswin, :mingw]
gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", platform: :jruby
end

gemspec path: "../"
12 changes: 12 additions & 0 deletions gemfiles/rails_5.2.gemfile
@@ -0,0 +1,12 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 5.2"

group :development, :test do
gem "sqlite3", platform: [:ruby, :mswin, :mingw]
gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", platform: :jruby
end

gemspec path: "../"
12 changes: 12 additions & 0 deletions gemfiles/rails_6.0.1.gemfile
@@ -0,0 +1,12 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 6.0.1"

group :development, :test do
gem "sqlite3", platform: [:ruby, :mswin, :mingw]
gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", platform: :jruby
end

gemspec path: "../"
3 changes: 0 additions & 3 deletions lib/wicked/controller/concerns/path.rb
@@ -1,7 +1,6 @@
module Wicked::Controller::Concerns::Path
extend ActiveSupport::Concern


def next_wizard_path(options = {})
wizard_path(@next_step, options)
end
Expand All @@ -18,7 +17,6 @@ def wicked_action
params[:action]
end


def wizard_path(goto_step = nil, options = {})
options = options.respond_to?(:to_h) ? options.to_h : options
options = { :controller => wicked_controller,
Expand All @@ -29,4 +27,3 @@ def wizard_path(goto_step = nil, options = {})
url_for(options)
end
end

1 change: 0 additions & 1 deletion lib/wicked/controller/concerns/render_redirect.rb
@@ -1,7 +1,6 @@
module Wicked::Controller::Concerns::RenderRedirect
extend ActiveSupport::Concern


def render_wizard(resource = nil, options = {}, params = {})
process_resource!(resource, options)

Expand Down
10 changes: 3 additions & 7 deletions lib/wicked/controller/concerns/steps.rb
Expand Up @@ -83,26 +83,22 @@ def previous_step(current_step = nil)
step ||= steps.first
end


def next_step(current_step = nil)
return @next_step if current_step.nil?
index = steps.index(current_step)
step = steps.at(index + 1) if index.present?
step ||= Wicked::FINISH_STEP
end

private

def step_index_for(step_name)
private def step_index_for(step_name)
steps.index(step_name)
end

def current_step_index
private def current_step_index
step_index_for(step)
end

def current_and_given_step_exists?(step_name)
private def current_and_given_step_exists?(step_name)
current_step_index.present? && steps.index(step_name).present?
end
end

20 changes: 10 additions & 10 deletions lib/wicked/wizard.rb
Expand Up @@ -15,7 +15,6 @@ def initialize
end

# Include the modules!!

include Wicked::Controller::Concerns::Path
include Wicked::Controller::Concerns::RenderRedirect
include Wicked::Controller::Concerns::Steps
Expand All @@ -28,7 +27,7 @@ def initialize
:past_step?, :future_step?, :previous_step?,
:next_step?
# Set @step and @next_step variables
before_action :setup_wizard
before_action :initialize_wicked_variables, :setup_wizard
end

# forward to first step with whatever params are provided
Expand All @@ -41,14 +40,17 @@ def wizard_value(step_name)
step_name
end

private
private def initialize_wicked_variables
@skip_to = nil
@wicked_redirect_params = nil
end

def check_redirect_to_first_last!(step)
private def check_redirect_to_first_last!(step)
redirect_to wizard_path(steps.first) if step.to_s == Wicked::FIRST_STEP
redirect_to wizard_path(steps.last) if step.to_s == Wicked::LAST_STEP
end

def setup_step_from(the_step)
private def setup_step_from(the_step)
return if steps.nil?

the_step ||= steps.first
Expand All @@ -61,23 +63,21 @@ def setup_step_from(the_step)
the_step
end

def check_steps!
private def check_steps!
raise UndefinedStepsError if steps.nil?
end

def set_previous_next(step)
private def set_previous_next(step)
@previous_step = previous_step(step)
@next_step = next_step(step)
end

def setup_wizard
private def setup_wizard
check_steps!
return if params[:id].nil?

@step = setup_step_from(params[:id])
set_previous_next(@step)
end
public
end
end

5 changes: 1 addition & 4 deletions lib/wicked/wizard/translated.rb
Expand Up @@ -57,7 +57,6 @@ def wizard_value(step_name)
end


private
# sets up a translated wizard controller
# translations are expected under the 'wicked' namespace
#
Expand All @@ -74,12 +73,10 @@ def wizard_value(step_name)
#
# steps "wicked.first", "wicked.second"
#
def setup_wizard_translated
private def setup_wizard_translated
self.steps = wizard_translations.keys # must come before setting previous/next steps
setup_wizard
end
public
end
end
end

1 change: 0 additions & 1 deletion lib/wicked/wizard_controller.rb
Expand Up @@ -35,4 +35,3 @@ class Wicked::WizardController < ApplicationController
# render_wizard @user
# end
end

18 changes: 9 additions & 9 deletions test/test_helper.rb
@@ -1,15 +1,10 @@
# Configure Rails Envinronment
ENV["RAILS_ENV"] = "test"



ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require "rails/test_help"




ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.default_url_options[:host] = "test.com"
Expand All @@ -21,10 +16,15 @@
Capybara.default_driver = :rack_test
Capybara.default_selector = :css



# Run any available migration
ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
# https://github.com/plataformatec/devise/blob/master/test/orm/active_record.rb
migrate_path = File.expand_path("../rails_app/db/migrate", __FILE__)
if Rails.version.start_with? '6'
ActiveRecord::MigrationContext.new(migrate_path, ActiveRecord::SchemaMigration).migrate
elsif Rails.version.start_with? '5.2'
ActiveRecord::MigrationContext.new(migrate_path).migrate
else
ActiveRecord::Migrator.migrate(migrate_path)
end

# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
Expand Down

0 comments on commit aa47805

Please sign in to comment.