Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove Rails 4 deprecations, round 2 #338

Merged
merged 2 commits into from
Jan 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ require 'rspec/core/rake_task'
desc "Run all specs in spec directory (excluding plugin specs)"
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')

# @deprecation - remove require when we drop Rails 4 support
require 'sub_test_task_patch'

require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/fae/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def body_class

def change_item_link(change)
text = "#{change.changeable_type}: "
test_source_method = Rails::VERSION::MAJOR > 4 ? :data_source_exists? : :table_exists?
test_source_method = :data_source_exists?

if change.changeable_type.exclude?('Fae') && change.changeable_type.exclude?('Page') && !ActiveRecord::Base.connection.send(test_source_method, change.changeable_type.tableize)
return "#{change.changeable_type}: model destroyed"
Expand Down
6 changes: 0 additions & 6 deletions app/models/concerns/fae/base_model_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ def order_method
end
end

# @depreciation - deprecate in v2.0
def filter_all
# override this method in your model
for_fae_index
end

def filter(params)
# override this method in your model
for_fae_index
Expand Down
6 changes: 1 addition & 5 deletions app/views/fae/shared/_form_header.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@ header.content-header.js-content-header

- if subnav.present?
ul.content-header-subnav#js-content-header-subnav
ruby:
# @depreciation - remove conditional when Rails 4 support is dropped, below becomes:
# link.parameterize(separator: '_')
parameterize_argument = Rails::VERSION::MAJOR == 4 ? '_' : { separator: '_' }
- subnav.each do |link, id_selector|
- subnav_item = link.is_a?(Array) ? link : [link, link.parameterize(parameterize_argument)]
- subnav_item = link.is_a?(Array) ? link : [link, link.parameterize(separator: '_')]
li: a href="##{subnav_item[1]}" = subnav_item[0]

- if show_flash_messages
Expand Down
18 changes: 0 additions & 18 deletions app/views/fae/shared/_nested_table_advanced.html.slim

This file was deleted.

10 changes: 0 additions & 10 deletions docs/features/filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,6 @@ def self.filter(params)
end
```

#### filter_all

There's also a `ModelName#filter_all` which is called when you reset the filter form. This defaults to the `for_fae_index` scope, but you can override it if you need to.

```ruby
def self.filter_all
where.not(name: 'John').order(:position)
end
```

### Fae Filter Form

```ruby
Expand Down
2 changes: 1 addition & 1 deletion lib/fae/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module Fae
# configurable defaults
class << self
mattr_accessor :devise_secret_key, :devise_mailer_sender, :dashboard_exclusions, :max_image_upload_size, :max_file_upload_size, :languages, :recreate_versions, :validation_helpers, :track_changes, :tracker_history_length, :slug_separator, :has_top_nav, :disabled_environments, :per_page, :use_cache
mattr_accessor :devise_secret_key, :devise_mailer_sender, :dashboard_exclusions, :max_image_upload_size, :max_file_upload_size, :languages, :recreate_versions, :validation_helpers, :track_changes, :tracker_history_length, :slug_separator, :disabled_environments, :per_page, :use_cache

self.devise_secret_key = ''
self.devise_mailer_sender = 'change-me@example.com'
Expand Down
129 changes: 0 additions & 129 deletions lib/sub_test_task_patch.rb

This file was deleted.

3 changes: 0 additions & 3 deletions spec/dummy/Rakefile
Original file line number Diff line number Diff line change
@@ -1,9 +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.

# @deprecation - remove require after deprecating Rails 4
require_relative '../../lib/sub_test_task_patch'

require File.expand_path('../config/application', __FILE__)

Rails.application.load_tasks
2 changes: 1 addition & 1 deletion spec/dummy/app/views/admin/aromas/table.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= render 'fae/shared/nested_table_advanced',
= render 'fae/shared/nested_table',
assoc: :aromas,
parent_item: @parent_item,
cols: [{ attr: :name, title: 'Pew Pew' }, :live, :image, { attr: :cat_size, title: 'Kitten Count' }],
Expand Down
1 change: 0 additions & 1 deletion spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class Application < Rails::Application
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.i18n.available_locales = [:en, :zh]
config.active_record.raise_in_transactional_callbacks = true if Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 2

config.action_controller.include_all_helpers = false
end
Expand Down
12 changes: 3 additions & 9 deletions spec/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,9 @@
config.eager_load = false

# Configure static asset server for tests with Cache-Control for performance.
if Rails::VERSION::MAJOR <= 4
# The following settings are depreciated in Rails 5
config.serve_static_files = true
config.static_cache_control = 'public, max-age=3600'
else
config.public_file_server.enabled = true
config.public_file_server.headers = 'public, max-age=3600'
config.action_mailer.default_url_options = { host: '127.0.0.1' }
end
config.public_file_server.enabled = true
config.public_file_server.headers = 'public, max-age=3600'
config.action_mailer.default_url_options = { host: '127.0.0.1' }

# Show full error reports and disable caching.
config.consider_all_requests_local = true
Expand Down
3 changes: 0 additions & 3 deletions spec/dummy/config/initializers/fae.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,4 @@
ja: 'Japanese'
}

# has_top_nav has been deprecated, but keeping in to ensure definition doesn't rasie exceptions
config.has_top_nav = true

end
6 changes: 1 addition & 5 deletions spec/requests/fae/changes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@

it 'should update Fae::Change.current_user with current_user' do
user = create_super_user
if Rails::VERSION::MAJOR > 4
post fae.user_session_path, params: { user: { 'email' => user.email, 'password' => user.password } }
else
post_via_redirect fae.user_session_path, 'user[email]' => user.email, 'user[password]' => user.password
end
post fae.user_session_path, params: { user: { 'email' => user.email, 'password' => user.password } }

get fae.root_path

Expand Down
6 changes: 1 addition & 5 deletions spec/requests/fae/setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@
password_confirmation: 'password'
}

if Rails::VERSION::MAJOR > 4
post fae.first_user_path, params: { user: user_params }
else
post fae.first_user_path, user: user_params
end
post fae.first_user_path, params: { user: user_params }

expect(response).to redirect_to(fae.root_path)
end
Expand Down
25 changes: 7 additions & 18 deletions spec/requests/fae/utilites_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,20 @@
it "shouldn't be able to toggle user's active attr" do
create_super_user

if Rails::VERSION::MAJOR > 4
post '/admin/toggle/fae_users/1/active', as: :js
follow_redirect!

expect(response.body).to include(I18n.t(:devise)[:failure][:unauthenticated])
else
post '/admin/toggle/fae_users/1/active', format: :js
expect(response.status).to eq(401)
end
post '/admin/toggle/fae_users/1/active', as: :js
follow_redirect!

expect(response.body).to include(I18n.t(:devise)[:failure][:unauthenticated])
end

it "shouldn't be able to toggle release's on_prod attr" do
create_super_user
release = FactoryGirl.create(:release)

if Rails::VERSION::MAJOR > 4
post "/admin/toggle/releases/#{release.id}/on_prod", as: :js
follow_redirect!

expect(response.body).to include(I18n.t(:devise)[:failure][:unauthenticated])
else
post "/admin/toggle/releases/#{release.id}/on_prod", format: :js
post "/admin/toggle/releases/#{release.id}/on_prod", as: :js
follow_redirect!

expect(response.status).to eq(401)
end
expect(response.body).to include(I18n.t(:devise)[:failure][:unauthenticated])
end
end

Expand Down
10 changes: 4 additions & 6 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@
# config.allow_url('gravatar.com')

# https://github.com/rails/rails-controller-testing#rspec
if Rails::VERSION::MAJOR > 4
[:controller, :view, :request].each do |type|
config.include ::Rails::Controller::Testing::TestProcess, :type => type
config.include ::Rails::Controller::Testing::TemplateAssertions, :type => type
config.include ::Rails::Controller::Testing::Integration, :type => type
end
[:controller, :view, :request].each do |type|
config.include ::Rails::Controller::Testing::TestProcess, :type => type
config.include ::Rails::Controller::Testing::TemplateAssertions, :type => type
config.include ::Rails::Controller::Testing::Integration, :type => type
end
end

Expand Down
12 changes: 4 additions & 8 deletions spec/support/devise_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,11 @@ def login(user)

module SignInRequestHelper
def login(user)
if Rails::VERSION::MAJOR > 4
post fae.user_session_path, params: { user: { 'email' => user.email, 'password' => user.password } }
post fae.user_session_path, params: { user: { 'email' => user.email, 'password' => user.password } }

# this should work, but it's effecting the route variables, possible related to
# https://github.com/plataformatec/devise/issues/4127
# follow_redirect!
else
post_via_redirect fae.user_session_path, 'user[email]' => user.email, 'user[password]' => user.password
end
# this should work, but it's effecting the route variables, possible related to
# https://github.com/plataformatec/devise/issues/4127
# follow_redirect!
end
end

Expand Down