Skip to content

Commit

Permalink
Rails 5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
glebm committed Apr 16, 2016
1 parent ab92f3a commit 9418750
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ gemfile:
- spec/gemfiles/rails_4_0.gemfile
- spec/gemfiles/rails_4_1.gemfile
- spec/gemfiles/rails_4_2.gemfile
- spec/gemfiles/rails_5_0.gemfile
git:
submodules: false
env:
Expand All @@ -23,4 +24,4 @@ matrix:
gemfile: spec/gemfiles/rails_3_2.gemfile
sudo: false
cache: bundler
bundler_args: --path ../../vendor/bundle --without debug
bundler_args: --path ../../vendor/bundle --without debug
8 changes: 6 additions & 2 deletions app/controllers/rails_email_preview/emails_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def show

# Really deliver an email
def test_deliver
redirect_url = rails_email_preview.rep_email_url(params.slice(:preview_id, :email_locale))
redirect_url = rails_email_preview.rep_email_url(preview_params.except(:recipient_email))
if (address = params[:recipient_email]).blank? || address !~ /@/
redirect_to redirect_url, alert: t('rep.test_deliver.provide_email')
return
Expand Down Expand Up @@ -74,7 +74,11 @@ def show_body
private

def preview_params
params.except(*(request.path_parameters.keys - [:email_locale]))
if Rails::VERSION::MAJOR >= 5
params.to_unsafe_h.except(*(request.path_parameters.keys - [:email_locale]))
else
params.except(*(request.path_parameters.keys - [:email_locale]))
end
end

def deliver_email!(mail)
Expand Down
3 changes: 1 addition & 2 deletions rails_email_preview.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ Gem::Specification.new do |s|

s.add_development_dependency 'i18n-tasks', '>= 0.7.6'
s.add_development_dependency 'capybara', '>= 2.3.0'
s.add_development_dependency 'rspec', '~> 3.4'
s.add_development_dependency 'rspec-rails'
s.add_development_dependency 'rspec-rails', '>= 3.4'
s.add_development_dependency 'poltergeist'

s.version = RailsEmailPreview::VERSION
Expand Down
4 changes: 1 addition & 3 deletions spec/dummy/config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)

require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
require 'bundler/setup'
1 change: 1 addition & 0 deletions spec/gemfiles/rails_3_2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ source "http://rubygems.org"
gemspec path: '../..'

gem 'rails', '~> 3.2.17'
gem 'test-unit', '~> 3.0'

eval_gemfile './shared.gemfile'
12 changes: 12 additions & 0 deletions spec/gemfiles/rails_5_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
source 'http://rubygems.org'

gemspec path: '../..'

gem 'rails', '~> 5.0.0.beta3'

gem 'sass-rails', '~> 5.0.1'
group :test do
gem 'rspec-rails', '~> 3.5.0.beta3'
end

eval_gemfile './shared.gemfile'

0 comments on commit 9418750

Please sign in to comment.