validates_overlap 0.8.6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 887de1441f7986508de96a9fa513847b67ff47fb
4
- data.tar.gz: 98ff051afa57c042628eefa246b48d53717babfb
2
+ SHA256:
3
+ metadata.gz: a4cb1a64ca3a5f173591cc6e6ee54268711a12dc49da4e8e5041aedd94f40e81
4
+ data.tar.gz: ad351e1f69f9c6f05dc9a38b6d23530672bc986fb19d48e890ba4a94e14ee9ba
5
5
  SHA512:
6
- metadata.gz: 302740541f1b75fc706bb98e9c26da12c9a2b966842240cca98f0aeeecf1ea801c9849da260453867d373f2d00c06390be87bd955d8253ecb103c088b53b6a33
7
- data.tar.gz: 225d5db1e766e50af82cb0ebddc11f79b965ccc12fe8c3ca2d7a3ccd05603c289a4e01d2696245e28696cb7234f5ed3ed809833f0108ed8a2d4fdb431c5e24f8
6
+ metadata.gz: 0da45c30fd0a89545921403ed0956891c3828a42494130369bc9ffba80a36070beeead19caac80c9ef0ce21773cd355f73dbab9fc8750f2ab19df0d28acb5d0a
7
+ data.tar.gz: 4c3d245beba5c257f8682d2ff23dcc491caede32a68237a12838965da94101e520bd975ab761ef86d66cf44e9ac8065381612f756b2d3a93d76db3d2f87d279d
@@ -1,10 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
3
+ - 2.5.0
4
4
  gemfile:
5
- - Gemfile.rails30
6
- - Gemfile.rails32
7
- - Gemfile.rails40
8
- - Gemfile.rails41
9
- - Gemfile.rails42
10
- - Gemfile.rails50
5
+ - Gemfile.rails60
6
+ script: bundle exec rspec
@@ -2,4 +2,4 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 5.0'
5
+ gem 'rails', '~> 6.0'
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  This project rocks and uses MIT-LICENSE.
6
6
 
7
- #### This gem is compatible with Rails 3, 4, 5.
7
+ #### 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 .
8
8
 
9
9
  #### When this gem should be helpful for you?
10
10
  Ideal solution for booking applications where you want to make sure, that one place can be booked only once in specific time period.
@@ -62,7 +62,7 @@ class Position < ActiveRecord::Base
62
62
  belongs_to :user
63
63
  validates "time_slots.starts_at", "time_slots.ends_at",
64
64
  :overlap => {
65
- :query_options => {:includes => :time_slot},
65
+ :query_options => {:joins => :time_slot},
66
66
  :scope => { "positions.user_id" => proc{|position| position.user_id} }
67
67
  }
68
68
  end
@@ -90,18 +90,3 @@ class ActiveMeeting < ActiveRecord::Base
90
90
  end
91
91
 
92
92
  ```
93
-
94
- ## Rails 4.1 update
95
-
96
- 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
97
-
98
- ```ruby
99
- {:overlap => {:query_options => {:active => true}}}
100
- ```
101
-
102
- but this code is not longer working. Currently please change your code to
103
-
104
- ```ruby
105
- {:overlap => {:query_options => {:active => nil}}}
106
- ```
107
- Thanks @supertinou for discovering and fix of this bug.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.6
1
+ 1.0.0
@@ -0,0 +1,4 @@
1
+ ru:
2
+ errors:
3
+ messages:
4
+ overlap: пересекается с другой записью
@@ -40,7 +40,8 @@ class OverlapValidator < ActiveModel::EachValidator
40
40
  protected
41
41
 
42
42
  def initialize_query(record, options = {})
43
- self.scoped_model = options[:scoped_model].present? ? options[:scoped_model].constantize : record.class
43
+ scoped_model = options[:scoped_model].present? ? options[:scoped_model].constantize : record.class
44
+ self.scoped_model = scoped_model.default_scoped
44
45
  generate_overlap_sql_values(record)
45
46
  generate_overlap_sql_conditions(record)
46
47
  add_attributes(record, options[:scope]) if options && options[:scope].present?
@@ -3,7 +3,7 @@ class Position < ActiveRecord::Base
3
3
  belongs_to :user
4
4
  validates :"time_slots.starts_at", :"time_slots.ends_at",
5
5
  overlap: {
6
- query_options: { includes: :time_slot },
6
+ query_options: { joins: :time_slot },
7
7
  scope: { 'positions.user_id' => proc { |position| position.user_id } }
8
8
  }
9
9
  end
@@ -2,7 +2,7 @@ class TimeSlot < ActiveRecord::Base
2
2
  has_many :positions
3
3
  validates :"time_slots.starts_at", :"time_slots.ends_at",
4
4
  overlap: {
5
- query_options: { includes: :positions },
5
+ query_options: { joins: :positions },
6
6
  scope: { 'positions.user_id' => proc { |time_slot| time_slot.positions.map(&:user_id) } }
7
7
  }
8
8
  end
@@ -1,4 +1,4 @@
1
- class CreateMeetings < ActiveRecord::Migration
1
+ class CreateMeetings < ActiveRecord::Migration[6.0]
2
2
  def self.up
3
3
  create_table :meetings do |t|
4
4
  t.date :starts_at
@@ -1,4 +1,4 @@
1
- class CreateUsers < ActiveRecord::Migration
1
+ class CreateUsers < ActiveRecord::Migration[6.0]
2
2
  def self.up
3
3
  create_table :users do |t|
4
4
  t.string :name
@@ -1,4 +1,4 @@
1
- class CreateUserMeetings < ActiveRecord::Migration
1
+ class CreateUserMeetings < ActiveRecord::Migration[6.0]
2
2
  def self.up
3
3
  create_table :user_meetings do |t|
4
4
  t.integer :user_id
@@ -1,4 +1,4 @@
1
- class CreateEndOverlapMeetings < ActiveRecord::Migration
1
+ class CreateEndOverlapMeetings < ActiveRecord::Migration[6.0]
2
2
  def self.up
3
3
  create_table :end_overlap_meetings do |t|
4
4
  t.date :starts_at
@@ -1,4 +1,4 @@
1
- class CreateStartOverlapMeetings < ActiveRecord::Migration
1
+ class CreateStartOverlapMeetings < ActiveRecord::Migration[6.0]
2
2
  def self.up
3
3
  create_table :start_overlap_meetings do |t|
4
4
  t.date :starts_at
@@ -1,4 +1,4 @@
1
- class CreateStartEndOverlapMeetings < ActiveRecord::Migration
1
+ class CreateStartEndOverlapMeetings < ActiveRecord::Migration[6.0]
2
2
  def self.up
3
3
  create_table :start_end_overlap_meetings do |t|
4
4
  t.date :starts_at
@@ -1,4 +1,4 @@
1
- class CreateTimeSlot < ActiveRecord::Migration
1
+ class CreateTimeSlot < ActiveRecord::Migration[6.0]
2
2
  def self.up
3
3
  create_table :time_slots do |t|
4
4
  t.date :starts_at
@@ -1,4 +1,4 @@
1
- class CreateActiveMeetings < ActiveRecord::Migration
1
+ class CreateActiveMeetings < ActiveRecord::Migration[6.0]
2
2
  def self.up
3
3
  create_table :active_meetings do |t|
4
4
  t.date :starts_at
@@ -1,4 +1,4 @@
1
- class CreateSecureMeetings < ActiveRecord::Migration
1
+ class CreateSecureMeetings < ActiveRecord::Migration[6.0]
2
2
  def self.up
3
3
  create_table :secure_meetings, id: false do |t|
4
4
  t.primary_key :id
@@ -1,4 +1,4 @@
1
- class CreateShifts < ActiveRecord::Migration
1
+ class CreateShifts < ActiveRecord::Migration[6.0]
2
2
  def self.up
3
3
  create_table :shifts do |t|
4
4
  t.date :starts_at
@@ -1,4 +1,4 @@
1
- class AddDocumentsWithEnum < ActiveRecord::Migration
1
+ class AddDocumentsWithEnum < ActiveRecord::Migration[6.0]
2
2
  def self.up
3
3
  create_table :documents_with_enum do |t|
4
4
  t.date :valid_from
@@ -15,7 +15,7 @@ ActionMailer::Base.default_url_options[:host] = 'test.com'
15
15
  Rails.backtrace_cleaner.remove_silencers!
16
16
 
17
17
  # Run any available migration
18
- ActiveRecord::Migrator.migrate File.expand_path('../dummy/db/migrate/', __FILE__)
18
+ ActiveRecord::MigrationContext.new(File.expand_path('../dummy/db/migrate/', __FILE__), ActiveRecord::SchemaMigration).migrate
19
19
 
20
20
  # Load support files
21
21
  FactoryGirl.definition_file_paths << File.join(File.dirname(__FILE__), '/dummy/spec/factories')
@@ -43,6 +43,8 @@ RSpec.configure do |config|
43
43
  end
44
44
  end
45
45
 
46
+
47
+
46
48
  OVERLAP_TIME_RANGES = {
47
49
  'has same starts_at and ends_at' => ['2011-01-05'.to_date, '2011-01-08'.to_date],
48
50
  'starts before starts_at and ends after ends_at' => ['2011-01-04'.to_date, '2011-01-09'.to_date],
@@ -18,14 +18,13 @@ Gem::Specification.new do |s|
18
18
  s.licenses = ['MIT']
19
19
  s.require_paths = ['lib']
20
20
  s.summary = 'This gem helps validate records with time overlap.'
21
- s.add_dependency 'rails', '>= 3.0.0'
21
+ s.add_dependency 'rails', '>= 6.0.0'
22
22
  s.add_development_dependency 'sqlite3'
23
- s.add_development_dependency 'rspec-rails', '~>2.12'
24
- s.add_development_dependency 'factory_girl_rails', '~>4.2'
25
- s.add_development_dependency 'bundler', '~>1.2'
23
+ s.add_development_dependency 'rspec-rails'
24
+ s.add_development_dependency 'factory_girl_rails'
25
+ s.add_development_dependency 'bundler'
26
26
  s.add_development_dependency 'pry'
27
27
  s.add_development_dependency 'rb-readline'
28
28
  s.add_development_dependency 'database_cleaner'
29
29
  s.add_development_dependency 'rubocop'
30
- s.add_development_dependency 'test-unit'
31
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_overlap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Bortlik
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.0.0
19
+ version: 6.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 3.0.0
26
+ version: 6.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -42,46 +42,32 @@ dependencies:
42
42
  name: rspec-rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '2.12'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '2.12'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: factory_girl_rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '4.2'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '4.2'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1.2'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1.2'
83
- - !ruby/object:Gem::Dependency
84
- name: pry
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - ">="
@@ -95,7 +81,7 @@ dependencies:
95
81
  - !ruby/object:Gem::Version
96
82
  version: '0'
97
83
  - !ruby/object:Gem::Dependency
98
- name: rb-readline
84
+ name: pry
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
87
  - - ">="
@@ -109,7 +95,7 @@ dependencies:
109
95
  - !ruby/object:Gem::Version
110
96
  version: '0'
111
97
  - !ruby/object:Gem::Dependency
112
- name: database_cleaner
98
+ name: rb-readline
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - ">="
@@ -123,7 +109,7 @@ dependencies:
123
109
  - !ruby/object:Gem::Version
124
110
  version: '0'
125
111
  - !ruby/object:Gem::Dependency
126
- name: rubocop
112
+ name: database_cleaner
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
115
  - - ">="
@@ -137,7 +123,7 @@ dependencies:
137
123
  - !ruby/object:Gem::Version
138
124
  version: '0'
139
125
  - !ruby/object:Gem::Dependency
140
- name: test-unit
126
+ name: rubocop
141
127
  requirement: !ruby/object:Gem::Requirement
142
128
  requirements:
143
129
  - - ">="
@@ -163,12 +149,7 @@ files:
163
149
  - ".rubocop.yml"
164
150
  - ".travis.yml"
165
151
  - Gemfile
166
- - Gemfile.rails30
167
- - Gemfile.rails32
168
- - Gemfile.rails40
169
- - Gemfile.rails41
170
- - Gemfile.rails42
171
- - Gemfile.rails50
152
+ - Gemfile.rails60
172
153
  - MIT-LICENSE
173
154
  - README.md
174
155
  - Rakefile
@@ -177,6 +158,7 @@ files:
177
158
  - lib/validates_overlap/locale/en.yml
178
159
  - lib/validates_overlap/locale/es.yml
179
160
  - lib/validates_overlap/locale/pt-BR.yml
161
+ - lib/validates_overlap/locale/ru.yml
180
162
  - lib/validates_overlap/overlap_validator.rb
181
163
  - spec/dummy/Rakefile
182
164
  - spec/dummy/app/controllers/application_controller.rb
@@ -280,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
280
262
  version: '0'
281
263
  requirements: []
282
264
  rubyforge_project:
283
- rubygems_version: 2.6.8
265
+ rubygems_version: 2.7.3
284
266
  signing_key:
285
267
  specification_version: 4
286
268
  summary: This gem helps validate records with time overlap.
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- gem 'rails', '~> 3.0.0'
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- gem 'rails', '~> 3.2.0'
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- gem 'rails', '~> 4.0.0'
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- gem 'rails', '~> 4.1.0.rc1'
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- gem 'rails', '~> 4.2.0.beta4'