Skip to content

Commit

Permalink
allow rails 5.1 usage
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoamaro committed May 2, 2017
1 parent f292aff commit 2abf423
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 20 deletions.
8 changes: 8 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ appraise "rails50" do

gem "rails-controller-testing"
end

appraise "rails51" do
gem "actionpack", "~> 5.1.0"
gem "actionview", "~> 5.1.0"
gem "activerecord", "~> 5.1.0"

gem "rails-controller-testing"
end
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ PATH
remote: .
specs:
administrate (0.6.0)
actionpack (>= 4.2, < 5.1)
actionview (>= 4.2, < 5.1)
activerecord (>= 4.2, < 5.1)
actionpack (>= 4.2, < 5.2)
actionview (>= 4.2, < 5.2)
activerecord (>= 4.2, < 5.2)
autoprefixer-rails (~> 6.0)
bourbon (>= 5.0.0.beta.6)
datetime_picker_rails (~> 0.0.7)
Expand Down
6 changes: 3 additions & 3 deletions administrate.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Gem::Specification.new do |s|
s.files = Dir["{app,config,db,lib,docs}/**/*", "LICENSE", "Rakefile"]
s.test_files = Dir["test/**/*"]

s.add_dependency "actionpack", ">= 4.2", "< 5.1"
s.add_dependency "actionview", ">= 4.2", "< 5.1"
s.add_dependency "activerecord", ">= 4.2", "< 5.1"
s.add_dependency "actionpack", ">= 4.2", "< 5.2"
s.add_dependency "actionview", ">= 4.2", "< 5.2"
s.add_dependency "activerecord", ">= 4.2", "< 5.2"

s.add_dependency "autoprefixer-rails", "~> 6.0"
s.add_dependency "bourbon", ">= 5.0.0.beta.6"
Expand Down
47 changes: 47 additions & 0 deletions gemfiles/rails51.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "administrate-field-image"
gem "autoprefixer-rails"
gem "bourbon", "~> 5.0.0.beta.7"
gem "faker"
gem "pg"
gem "redcarpet"
gem "sentry-raven"
gem "unicorn"
gem "actionpack", "~> 5.1.0"
gem "actionview", "~> 5.1.0"
gem "activerecord", "~> 5.1.0"
gem "rails-controller-testing"

group :development, :test do
gem "appraisal"
gem "awesome_print"
gem "bundler-audit", :require => false
gem "byebug"
gem "dotenv-rails"
gem "factory_girl_rails"
gem "i18n-tasks"
gem "pry-rails"
gem "rspec-rails", "~> 3.5.0"
end

group :test do
gem "ammeter"
gem "database_cleaner"
gem "formulaic"
gem "launchy"
gem "poltergeist"
gem "shoulda-matchers", "~> 2.8.0", :require => false
gem "timecop"
gem "webmock"
end

group :staging, :production do
gem "rack-timeout"
gem "rails_stdout_logging"
gem "uglifier"
end

gemspec :path => "../"
58 changes: 44 additions & 14 deletions spec/support/http_method_shims.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,57 @@
module HTTPMethodShim
def get(path, params = nil, headers = nil)
super(path, params: params, headers: headers)
end
module Rails50
def get(path, params = nil, headers = nil)
super(path, params: params, headers: headers)
end

def post(path, params = nil, headers = nil)
super(path, params: params, headers: headers)
end
def post(path, params = nil, headers = nil)
super(path, params: params, headers: headers)
end

def put(path, params = nil, headers = nil)
super(path, params: params, headers: headers)
end

def put(path, params = nil, headers = nil)
super(path, params: params, headers: headers)
def patch(path, params = nil, headers = nil)
super(path, params: params, headers: headers)
end

def delete(path, params = nil, headers = nil)
super(path, params: params, headers: headers)
end
end

def patch(path, params = nil, headers = nil)
super(path, params: params, headers: headers)
module Rails51
def get(path, params = nil)
super(path, params: params.to_h)
end

def post(path, params = nil)
super(path, params: params.to_h)
end

def put(path, params = nil)
super(path, params: params.to_h)
end

def patch(path, params = nil)
super(path, params: params.to_h)
end

def delete(path, params = nil)
super(path, params: params.to_h)
end
end
end

def delete(path, params = nil, headers = nil)
super(path, params: params, headers: headers)
if Gem::Dependency.new('rails', '~> 5.1.0').match?('rails', Rails::VERSION::STRING)
RSpec.configure do |config|
config.include HTTPMethodShim::Rails51, type: :controller
end
end

if Rails::VERSION::MAJOR >= 5
if Gem::Dependency.new('rails', '~> 5.0.0').match?('rails', Rails::VERSION::STRING)
RSpec.configure do |config|
config.include HTTPMethodShim, type: :controller
config.include HTTPMethodShim::Rails50, type: :controller
end
end

0 comments on commit 2abf423

Please sign in to comment.