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 +5 -5
- data/.travis.yml +3 -7
- data/{Gemfile.rails50 → Gemfile.rails60} +1 -1
- data/README.md +2 -17
- data/VERSION +1 -1
- data/lib/validates_overlap/locale/ru.yml +4 -0
- data/lib/validates_overlap/overlap_validator.rb +2 -1
- data/spec/dummy/app/models/position.rb +1 -1
- data/spec/dummy/app/models/time_slot.rb +1 -1
- data/spec/dummy/db/migrate/20110406082020_create_meetings.rb +1 -1
- data/spec/dummy/db/migrate/20110406082053_create_users.rb +1 -1
- data/spec/dummy/db/migrate/20110407060725_create_user_meetings.rb +1 -1
- data/spec/dummy/db/migrate/20120509130956_create_end_overlap_meetings.rb +1 -1
- data/spec/dummy/db/migrate/20120509131012_create_start_overlap_meetings.rb +1 -1
- data/spec/dummy/db/migrate/20120509131032_create_start_end_overlap_meetings.rb +1 -1
- data/spec/dummy/db/migrate/20121207162212_create_time_slot.rb +1 -1
- data/spec/dummy/db/migrate/20130826155107_create_active_meetings.rb +1 -1
- data/spec/dummy/db/migrate/20150707155107_create_secure_meetings.rb +1 -1
- data/spec/dummy/db/migrate/20151203153132_create_shifts.rb +1 -1
- data/spec/dummy/db/migrate/20170102162952_add_documents_with_enum.rb +1 -1
- data/spec/spec_helper.rb +3 -1
- data/validates_overlap.gemspec +4 -5
- metadata +18 -36
- data/Gemfile.rails30 +0 -5
- data/Gemfile.rails32 +0 -5
- data/Gemfile.rails40 +0 -5
- data/Gemfile.rails41 +0 -5
- data/Gemfile.rails42 +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a4cb1a64ca3a5f173591cc6e6ee54268711a12dc49da4e8e5041aedd94f40e81
|
4
|
+
data.tar.gz: ad351e1f69f9c6f05dc9a38b6d23530672bc986fb19d48e890ba4a94e14ee9ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0da45c30fd0a89545921403ed0956891c3828a42494130369bc9ffba80a36070beeead19caac80c9ef0ce21773cd355f73dbab9fc8750f2ab19df0d28acb5d0a
|
7
|
+
data.tar.gz: 4c3d245beba5c257f8682d2ff23dcc491caede32a68237a12838965da94101e520bd975ab761ef86d66cf44e9ac8065381612f756b2d3a93d76db3d2f87d279d
|
data/.travis.yml
CHANGED
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,
|
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 => {:
|
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.
|
1
|
+
1.0.0
|
@@ -40,7 +40,8 @@ class OverlapValidator < ActiveModel::EachValidator
|
|
40
40
|
protected
|
41
41
|
|
42
42
|
def initialize_query(record, options = {})
|
43
|
-
|
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: {
|
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: {
|
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
|
data/spec/spec_helper.rb
CHANGED
@@ -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::
|
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],
|
data/validates_overlap.gemspec
CHANGED
@@ -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', '>=
|
21
|
+
s.add_dependency 'rails', '>= 6.0.0'
|
22
22
|
s.add_development_dependency 'sqlite3'
|
23
|
-
s.add_development_dependency 'rspec-rails'
|
24
|
-
s.add_development_dependency 'factory_girl_rails'
|
25
|
-
s.add_development_dependency 'bundler'
|
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.
|
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:
|
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:
|
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: '
|
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: '
|
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: '
|
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: '
|
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:
|
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:
|
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:
|
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:
|
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.
|
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.
|
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.
|
data/Gemfile.rails30
DELETED
data/Gemfile.rails32
DELETED
data/Gemfile.rails40
DELETED
data/Gemfile.rails41
DELETED