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

Fixes Rails 5.2.0 deprecation and change Travis-setup #121

Merged
merged 2 commits into from Feb 26, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions .travis.yml
@@ -1,7 +1,9 @@
language: ruby
rvm:
- 2.3.1
- 2.2.5
- 2.5.0
- 2.4.3
- 2.3.6
- 2.2.9
env:
- DB=postgresql
before_install:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

## Unreleased

* ActiveRecord 5.2 compatibility by wrapping string queries with `Arel.sql()`
* Adds latest Ruby, Rails and Postgres-dependencies to Travis.
* Rewrite development migration code to support Rails 5.0-5.2.

## 5.0.0

* ActiveRecord 5.1 compatibility
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
@@ -1,3 +1,5 @@
source 'https://rubygems.org'

gemspec

gem 'activerecord', '~> 5.2.x'
14 changes: 12 additions & 2 deletions Rakefile
Expand Up @@ -43,12 +43,22 @@ namespace :db do

desc 'Run the test database migrations'
task :up => :'db:connect' do
ActiveRecord::Migrator.up 'db/migrate'
migrations = if ActiveRecord.version.version >= '5.2'
ActiveRecord::Migration.new.migration_context.migrations
else
ActiveRecord::Migrator.migrations('db/migrate')
end
ActiveRecord::Migrator.new(:up, migrations, nil).migrate
end

desc 'Reverse the test database migrations'
task :down => :'db:connect' do
ActiveRecord::Migrator.down 'db/migrate'
migrations = if ActiveRecord.version.version >= '5.2'
ActiveRecord::Migration.new.migration_context.migrations
else
ActiveRecord::Migrator.migrations('db/migrate')
end
ActiveRecord::Migrator.new(:down, migrations, nil).migrate
end
end
task :migrate => :'migrate:up'
Expand Down
5 changes: 3 additions & 2 deletions gemfiles/activerecord-5.0.gemfile
@@ -1,5 +1,6 @@
source 'https://rubygems.org'

gemspec :path=>"../"
gemspec path: "../"

gem 'activerecord', '~> 5.0.x'
gem 'activerecord', '>= 5.0', '< 5.1'
gem 'pg', '~> 0.21'
2 changes: 1 addition & 1 deletion gemfiles/activerecord-5.1.gemfile
Expand Up @@ -2,4 +2,4 @@ source 'https://rubygems.org'

gemspec :path=>"../"

gem 'activerecord', '~> 5.1.x'
gem 'activerecord', '< 5.2', '>= 5.1'
4 changes: 2 additions & 2 deletions lib/textacular.rb
Expand Up @@ -123,9 +123,9 @@ def fuzzy_condition_string(table_name, column, search_term)
def assemble_query(similarities, conditions, exclusive)
rank = connection.quote_column_name('rank' + rand(100000000000000000).to_s)

select("#{quoted_table_name + '.*,' if select_values.empty?} #{similarities.join(" + ")} AS #{rank}").
select(Arel.sql("#{quoted_table_name + '.*,' if select_values.empty?} #{similarities.join(" + ")} AS #{rank}")).
where(conditions.join(exclusive ? " AND " : " OR ")).
order("#{rank} DESC")
order(Arel.sql("#{rank} DESC"))
end

def select_values
Expand Down
4 changes: 2 additions & 2 deletions textacular.gemspec
Expand Up @@ -56,12 +56,12 @@ Gem::Specification.new do |s|
]
s.require_paths = ['lib']

s.add_development_dependency 'pg', '~> 0.14'
s.add_development_dependency 'pg', '~> 1.0.0'
s.add_development_dependency 'rspec'
s.add_development_dependency 'database_cleaner'
s.add_development_dependency 'rake'
s.add_development_dependency 'pry'
s.add_development_dependency 'pry-doc'

s.add_dependency('activerecord', [">= 3.0", "< 5.2"])
s.add_dependency('activerecord', [">= 5.0", "< 5.3"])
end