Skip to content

Commit

Permalink
Merge pull request #53 from robinbortlik/rails60
Browse files Browse the repository at this point in the history
Rails60
  • Loading branch information
Robin Bortlík authored Nov 17, 2019
2 parents 25ee467 + 26c9784 commit 4c2c837
Show file tree
Hide file tree
Showing 24 changed files with 27 additions and 70 deletions.
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
language: ruby
rvm:
- 2.2.2
- 2.5.0
gemfile:
- Gemfile.rails30
- Gemfile.rails32
- Gemfile.rails40
- Gemfile.rails41
- Gemfile.rails42
- Gemfile.rails50
- Gemfile.rails60
script: bundle exec rspec
5 changes: 0 additions & 5 deletions Gemfile.rails30

This file was deleted.

5 changes: 0 additions & 5 deletions Gemfile.rails32

This file was deleted.

5 changes: 0 additions & 5 deletions Gemfile.rails40

This file was deleted.

5 changes: 0 additions & 5 deletions Gemfile.rails41

This file was deleted.

5 changes: 0 additions & 5 deletions Gemfile.rails42

This file was deleted.

2 changes: 1 addition & 1 deletion Gemfile.rails50 → Gemfile.rails60
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ source "https://rubygems.org"

gemspec

gem 'rails', '~> 5.0'
gem 'rails', '~> 6.0'
19 changes: 2 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This project rocks and uses MIT-LICENSE.

#### This gem is compatible with Rails 3, 4, 5.
#### This gem is compatible with Rails 6. If you are looking for version compatible with Rails 3,4,5 please use version 0.8.6 .

#### When this gem should be helpful for you?
Ideal solution for booking applications where you want to make sure, that one place can be booked only once in specific time period.
Expand Down Expand Up @@ -62,7 +62,7 @@ class Position < ActiveRecord::Base
belongs_to :user
validates "time_slots.starts_at", "time_slots.ends_at",
:overlap => {
:query_options => {:includes => :time_slot},
:query_options => {:joins => :time_slot},
:scope => { "positions.user_id" => proc{|position| position.user_id} }
}
end
Expand Down Expand Up @@ -90,18 +90,3 @@ class ActiveMeeting < ActiveRecord::Base
end

```

## Rails 4.1 update

If you just upgraded your application to rails 4.1 you can discover some issue with custom scopes. In older versions we suggest to use definition like

```ruby
{:overlap => {:query_options => {:active => true}}}
```

but this code is not longer working. Currently please change your code to

```ruby
{:overlap => {:query_options => {:active => nil}}}
```
Thanks @supertinou for discovering and fix of this bug.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.6
1.0.0
2 changes: 1 addition & 1 deletion spec/dummy/app/models/position.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Position < ActiveRecord::Base
belongs_to :user
validates :"time_slots.starts_at", :"time_slots.ends_at",
overlap: {
query_options: { includes: :time_slot },
query_options: { joins: :time_slot },
scope: { 'positions.user_id' => proc { |position| position.user_id } }
}
end
2 changes: 1 addition & 1 deletion spec/dummy/app/models/time_slot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class TimeSlot < ActiveRecord::Base
has_many :positions
validates :"time_slots.starts_at", :"time_slots.ends_at",
overlap: {
query_options: { includes: :positions },
query_options: { joins: :positions },
scope: { 'positions.user_id' => proc { |time_slot| time_slot.positions.map(&:user_id) } }
}
end
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/20110406082020_create_meetings.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateMeetings < ActiveRecord::Migration
class CreateMeetings < ActiveRecord::Migration[6.0]
def self.up
create_table :meetings do |t|
t.date :starts_at
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/20110406082053_create_users.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateUsers < ActiveRecord::Migration
class CreateUsers < ActiveRecord::Migration[6.0]
def self.up
create_table :users do |t|
t.string :name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateUserMeetings < ActiveRecord::Migration
class CreateUserMeetings < ActiveRecord::Migration[6.0]
def self.up
create_table :user_meetings do |t|
t.integer :user_id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateEndOverlapMeetings < ActiveRecord::Migration
class CreateEndOverlapMeetings < ActiveRecord::Migration[6.0]
def self.up
create_table :end_overlap_meetings do |t|
t.date :starts_at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateStartOverlapMeetings < ActiveRecord::Migration
class CreateStartOverlapMeetings < ActiveRecord::Migration[6.0]
def self.up
create_table :start_overlap_meetings do |t|
t.date :starts_at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateStartEndOverlapMeetings < ActiveRecord::Migration
class CreateStartEndOverlapMeetings < ActiveRecord::Migration[6.0]
def self.up
create_table :start_end_overlap_meetings do |t|
t.date :starts_at
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/20121207162212_create_time_slot.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateTimeSlot < ActiveRecord::Migration
class CreateTimeSlot < ActiveRecord::Migration[6.0]
def self.up
create_table :time_slots do |t|
t.date :starts_at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateActiveMeetings < ActiveRecord::Migration
class CreateActiveMeetings < ActiveRecord::Migration[6.0]
def self.up
create_table :active_meetings do |t|
t.date :starts_at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateSecureMeetings < ActiveRecord::Migration
class CreateSecureMeetings < ActiveRecord::Migration[6.0]
def self.up
create_table :secure_meetings, id: false do |t|
t.primary_key :id
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/20151203153132_create_shifts.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateShifts < ActiveRecord::Migration
class CreateShifts < ActiveRecord::Migration[6.0]
def self.up
create_table :shifts do |t|
t.date :starts_at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddDocumentsWithEnum < ActiveRecord::Migration
class AddDocumentsWithEnum < ActiveRecord::Migration[6.0]
def self.up
create_table :documents_with_enum do |t|
t.date :valid_from
Expand Down
4 changes: 3 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Rails.backtrace_cleaner.remove_silencers!

# Run any available migration
ActiveRecord::Migrator.migrate File.expand_path('../dummy/db/migrate/', __FILE__)
ActiveRecord::MigrationContext.new(File.expand_path('../dummy/db/migrate/', __FILE__), ActiveRecord::SchemaMigration).migrate

# Load support files
FactoryGirl.definition_file_paths << File.join(File.dirname(__FILE__), '/dummy/spec/factories')
Expand Down Expand Up @@ -43,6 +43,8 @@
end
end



OVERLAP_TIME_RANGES = {
'has same starts_at and ends_at' => ['2011-01-05'.to_date, '2011-01-08'.to_date],
'starts before starts_at and ends after ends_at' => ['2011-01-04'.to_date, '2011-01-09'.to_date],
Expand Down
9 changes: 4 additions & 5 deletions validates_overlap.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ Gem::Specification.new do |s|
s.licenses = ['MIT']
s.require_paths = ['lib']
s.summary = 'This gem helps validate records with time overlap.'
s.add_dependency 'rails', '>= 3.0.0'
s.add_dependency 'rails', '>= 6.0.0'
s.add_development_dependency 'sqlite3'
s.add_development_dependency 'rspec-rails', '~>2.12'
s.add_development_dependency 'factory_girl_rails', '~>4.2'
s.add_development_dependency 'bundler', '~>1.2'
s.add_development_dependency 'rspec-rails'
s.add_development_dependency 'factory_girl_rails'
s.add_development_dependency 'bundler'
s.add_development_dependency 'pry'
s.add_development_dependency 'rb-readline'
s.add_development_dependency 'database_cleaner'
s.add_development_dependency 'rubocop'
s.add_development_dependency 'test-unit'
end

0 comments on commit 4c2c837

Please sign in to comment.