snaps 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -13
- data/app/models/snaps/tag.rb +19 -5
- data/lib/snaps.rb +4 -0
- data/lib/snaps/snapshot.rb +5 -0
- data/lib/snaps/version.rb +1 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +145 -34
- data/spec/dummy/log/test.log +42500 -116
- data/spec/integration/revision_spec.rb +47 -4
- data/spec/models/tag_spec.rb +38 -0
- metadata +53 -51
@@ -44,6 +44,13 @@ describe "Snaps.revision" do
|
|
44
44
|
expect(snapshot.reload.title).to eq('zwei titel')
|
45
45
|
end
|
46
46
|
|
47
|
+
it "keeps create_at of record in snapshot" do
|
48
|
+
post = create(:post, title: 'ein titel')
|
49
|
+
snapshot = post.snapshot!
|
50
|
+
|
51
|
+
expect(post.created_at).to eq(snapshot.created_at)
|
52
|
+
end
|
53
|
+
|
47
54
|
it 'does not create a default tag' do
|
48
55
|
post = create(:post, title: 'ein titel')
|
49
56
|
|
@@ -167,11 +174,14 @@ describe "Snaps.revision" do
|
|
167
174
|
end
|
168
175
|
|
169
176
|
describe '.with_snaps_tag' do
|
170
|
-
it "returns list of records
|
177
|
+
it "returns list of records tagged with snaps_tags" do
|
171
178
|
post = create(:post)
|
172
179
|
post.snaps_tag!(:published)
|
173
180
|
|
174
|
-
|
181
|
+
posts = Post.with_snaps_tag(:published)
|
182
|
+
|
183
|
+
expect(posts.length).to eq(1)
|
184
|
+
expect(posts).to include(post)
|
175
185
|
end
|
176
186
|
|
177
187
|
it "does not return records with differnt tags" do
|
@@ -190,7 +200,7 @@ describe "Snaps.revision" do
|
|
190
200
|
post = create(:post)
|
191
201
|
post_snapshot = post.snapshot!
|
192
202
|
post.snaps_tag!(:published)
|
193
|
-
post_snapshot.snaps_tag!(:published)
|
203
|
+
post_snapshot.snaps_tag!(:published) # obsoletes tag on post
|
194
204
|
|
195
205
|
expect(Post.with_snaps_tag(:published).length).to eq(1)
|
196
206
|
expect(Post.with_snaps_tag(:published).first).to eq(post_snapshot)
|
@@ -201,7 +211,7 @@ describe "Snaps.revision" do
|
|
201
211
|
post = create(:post)
|
202
212
|
post_snapshot = post.snapshot!
|
203
213
|
post.snaps_tag!(:published)
|
204
|
-
post_snapshot.snaps_tag!(:published)
|
214
|
+
post_snapshot.snaps_tag!(:published) # obsoletes tag on post
|
205
215
|
|
206
216
|
result = Post.with_snaps_tag(:published, all_revisions: true)
|
207
217
|
|
@@ -211,4 +221,37 @@ describe "Snaps.revision" do
|
|
211
221
|
end
|
212
222
|
end
|
213
223
|
end
|
224
|
+
|
225
|
+
describe '.without_snaps_tag' do
|
226
|
+
it "returns list of records not tagged with snaps_tags" do
|
227
|
+
post = create(:post)
|
228
|
+
published_post = post.snapshot!(tag: :published)
|
229
|
+
|
230
|
+
posts = Post.without_snaps_tag(:published)
|
231
|
+
|
232
|
+
expect(posts.length).to eq(1)
|
233
|
+
expect(posts).to include(post)
|
234
|
+
expect(posts).not_to include(published_post)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
describe 'scope combinations' do
|
239
|
+
it 'are possible' do
|
240
|
+
a = create(:post)
|
241
|
+
a.snaps_tag!(:a)
|
242
|
+
|
243
|
+
b = create(:post)
|
244
|
+
b.snaps_tag!(:b)
|
245
|
+
|
246
|
+
ab = create(:post)
|
247
|
+
ab.snaps_tag!(:a)
|
248
|
+
ab.snaps_tag!(:b)
|
249
|
+
|
250
|
+
posts = Post.with_snaps_tag(:a).without_snaps_tag(:b)
|
251
|
+
|
252
|
+
expect(posts).not_to include(b)
|
253
|
+
expect(posts).not_to include(ab)
|
254
|
+
expect(posts).to include(a)
|
255
|
+
end
|
256
|
+
end
|
214
257
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Snaps::Tag do
|
4
|
+
describe '#for_all_revisions_of' do
|
5
|
+
it 'retruns a list of Tags for the passed record' do
|
6
|
+
post = create(:post, title: 'ein titel')
|
7
|
+
tag = post.snaps_tag!(:published)
|
8
|
+
|
9
|
+
tags = Snaps::Tag.for_all_revisions_of(post)
|
10
|
+
|
11
|
+
expect(tags).to include(tag)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#all_revisions_with_tag' do
|
16
|
+
it 'Returns a list of records tagged with the tagname' do
|
17
|
+
post = create(:post, title: 'ein titel')
|
18
|
+
post_snapshot = post.snapshot!(tag: :published)
|
19
|
+
|
20
|
+
posts = Snaps::Tag.all_revisions_with_tag(Post, :published)
|
21
|
+
|
22
|
+
expect(posts).to include(post_snapshot)
|
23
|
+
expect(posts).not_to include(post)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#all_revisions_without_tag' do
|
28
|
+
it 'Returns a list of records not tagged with the tagname' do
|
29
|
+
post = create(:post, title: 'Some Titel')
|
30
|
+
published_post = post.snapshot!(tag: :published)
|
31
|
+
|
32
|
+
posts = Snaps::Tag.all_revisions_without_tag(Post, :published)
|
33
|
+
|
34
|
+
expect(posts).to include(post)
|
35
|
+
expect(posts).not_to include(published_post)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snaps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Codevise Solutions Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: sqlite3
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -56,14 +56,14 @@ dependencies:
|
|
56
56
|
name: timecop
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
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
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
@@ -84,14 +84,14 @@ dependencies:
|
|
84
84
|
name: codeclimate-test-reporter
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
description: Revisioning and tagging of ActiveRecord models.
|
@@ -167,6 +167,7 @@ files:
|
|
167
167
|
- spec/dummy/spec/factories/sections.rb
|
168
168
|
- spec/integration/revision_spec.rb
|
169
169
|
- spec/integration/revision_spec.rb!
|
170
|
+
- spec/models/tag_spec.rb
|
170
171
|
- spec/spec_helper.rb
|
171
172
|
- spec/support/config/timecop.rb
|
172
173
|
homepage: https://github.com/codevise/snaps
|
@@ -179,69 +180,70 @@ require_paths:
|
|
179
180
|
- lib
|
180
181
|
required_ruby_version: !ruby/object:Gem::Requirement
|
181
182
|
requirements:
|
182
|
-
- -
|
183
|
+
- - '>='
|
183
184
|
- !ruby/object:Gem::Version
|
184
185
|
version: '0'
|
185
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
187
|
requirements:
|
187
|
-
- -
|
188
|
+
- - '>='
|
188
189
|
- !ruby/object:Gem::Version
|
189
190
|
version: '0'
|
190
191
|
requirements: []
|
191
192
|
rubyforge_project:
|
192
|
-
rubygems_version: 2.
|
193
|
+
rubygems_version: 2.2.2
|
193
194
|
signing_key:
|
194
195
|
specification_version: 4
|
195
196
|
summary: Revisioning and tagging of ActiveRecord models.
|
196
197
|
test_files:
|
197
198
|
- spec/support/config/timecop.rb
|
198
|
-
- spec/
|
199
|
-
- spec/
|
200
|
-
- spec/
|
201
|
-
- spec/dummy/
|
202
|
-
- spec/dummy/
|
203
|
-
- spec/dummy/
|
204
|
-
- spec/dummy/
|
205
|
-
- spec/dummy/app/controllers/application_controller.rb
|
206
|
-
- spec/dummy/Rakefile
|
207
|
-
- spec/dummy/README.rdoc
|
208
|
-
- spec/dummy/spec/factories/posts.rb
|
199
|
+
- spec/spec_helper.rb
|
200
|
+
- spec/integration/revision_spec.rb
|
201
|
+
- spec/integration/revision_spec.rb!
|
202
|
+
- spec/dummy/public/404.html
|
203
|
+
- spec/dummy/public/422.html
|
204
|
+
- spec/dummy/public/500.html
|
205
|
+
- spec/dummy/public/favicon.ico
|
209
206
|
- spec/dummy/spec/factories/sections.rb
|
210
|
-
- spec/dummy/
|
211
|
-
- spec/dummy/
|
207
|
+
- spec/dummy/spec/factories/posts.rb
|
208
|
+
- spec/dummy/README.rdoc
|
209
|
+
- spec/dummy/Rakefile
|
210
|
+
- spec/dummy/config.ru
|
211
|
+
- spec/dummy/bin/rake
|
212
212
|
- spec/dummy/bin/rails
|
213
213
|
- spec/dummy/bin/bundle
|
214
214
|
- spec/dummy/bin/setup
|
215
|
-
- spec/dummy/
|
216
|
-
- spec/dummy/config.
|
217
|
-
- spec/dummy/
|
218
|
-
- spec/dummy/
|
219
|
-
- spec/dummy/
|
220
|
-
- spec/dummy/db/migrate/20150321145225_create_posts.rb
|
221
|
-
- spec/dummy/db/migrate/20150323173024_create_sections.rb
|
222
|
-
- spec/dummy/db/migrate/20150324074047_create_snaps_tags.snaps.rb
|
223
|
-
- spec/dummy/public/422.html
|
224
|
-
- spec/dummy/public/404.html
|
225
|
-
- spec/dummy/public/favicon.ico
|
226
|
-
- spec/dummy/public/500.html
|
227
|
-
- spec/dummy/config/environments/production.rb
|
215
|
+
- spec/dummy/config/locales/en.yml
|
216
|
+
- spec/dummy/config/boot.rb
|
217
|
+
- spec/dummy/config/secrets.yml
|
218
|
+
- spec/dummy/config/application.rb
|
219
|
+
- spec/dummy/config/environment.rb
|
228
220
|
- spec/dummy/config/environments/test.rb
|
221
|
+
- spec/dummy/config/environments/production.rb
|
229
222
|
- spec/dummy/config/environments/development.rb
|
230
|
-
- spec/dummy/config/
|
223
|
+
- spec/dummy/config/database.yml
|
231
224
|
- spec/dummy/config/routes.rb
|
232
|
-
- spec/dummy/config/
|
233
|
-
- spec/dummy/config/initializers/session_store.rb
|
234
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
235
|
-
- spec/dummy/config/initializers/assets.rb
|
236
|
-
- spec/dummy/config/initializers/cookies_serializer.rb
|
225
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
237
226
|
- spec/dummy/config/initializers/inflections.rb
|
238
227
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
228
|
+
- spec/dummy/config/initializers/session_store.rb
|
229
|
+
- spec/dummy/config/initializers/cookies_serializer.rb
|
230
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
239
231
|
- spec/dummy/config/initializers/mime_types.rb
|
240
|
-
- spec/dummy/config/initializers/
|
241
|
-
- spec/dummy/
|
242
|
-
- spec/dummy/
|
243
|
-
- spec/dummy/
|
244
|
-
- spec/dummy/
|
245
|
-
- spec/
|
246
|
-
- spec/
|
247
|
-
- spec/
|
232
|
+
- spec/dummy/config/initializers/assets.rb
|
233
|
+
- spec/dummy/db/test.sqlite3
|
234
|
+
- spec/dummy/db/migrate/20150323173024_create_sections.rb
|
235
|
+
- spec/dummy/db/migrate/20150321145225_create_posts.rb
|
236
|
+
- spec/dummy/db/migrate/20150324074047_create_snaps_tags.snaps.rb
|
237
|
+
- spec/dummy/db/schema.rb
|
238
|
+
- spec/dummy/db/development.sqlite3
|
239
|
+
- spec/dummy/app/controllers/application_controller.rb
|
240
|
+
- spec/dummy/app/assets/javascripts/application.js
|
241
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
242
|
+
- spec/dummy/app/helpers/application_helper.rb
|
243
|
+
- spec/dummy/app/models/section.rb
|
244
|
+
- spec/dummy/app/models/post.rb
|
245
|
+
- spec/dummy/app/models/post_with_sections.rb
|
246
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
247
|
+
- spec/dummy/log/development.log
|
248
|
+
- spec/dummy/log/test.log
|
249
|
+
- spec/models/tag_spec.rb
|