mongoid-undo 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MGFkMDA3YTAxYTVkMDhjZjQ3ZDYzYTk4OWI5YjRlYTZlNDAzMTQ5Ng==
5
+ data.tar.gz: !binary |-
6
+ YjRmYTkwODJhNTg3YTA1M2QxZTNlOTExMmQzNDM5MTM1MzA2YWEyYg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ OThlNzY1ZDIxOTNmNzVhMzJkNGY1YmNjOTU4NTU3YjkzNTUxOTZhNzdjN2Mx
10
+ OTc1MzhkZTdiM2RhNTY4Yzk2NjAwN2M3YzEzNTE3NjNkZjgyZjI4ZDQzNDk5
11
+ MzllZDUzN2I3ZWY4ZDMyYmI4MjZkNTI5OTc3NzBmYjE5M2Y1OTY=
12
+ data.tar.gz: !binary |-
13
+ OGEyNDc3MzMyNjlhM2ViMmE3NzU1MGNkODFjYjRjMTcxMzM0ZDE3YTFkMmM3
14
+ MTk4ODJhZWQ2YzFkNDFhOTY1MGM3MmU2NDEwZWVlNTEwYmU4OTE1MjQ0OGQ5
15
+ NmZjOTIxNTQ3MzA2ZGFiMmU2N2QwY2M3YmZlMGYwODk5YzRmODU=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # 0.7.0 (February 8, 2014)
2
+ * Simpler tests.
3
+
4
+ # 0.6.0 (February 15, 2013)
5
+ * Updated Gemfile for Bundler 1.2.4+.
6
+ * Easier mongoid config.
7
+
1
8
  # 0.5.0 (February 14, 2013)
2
9
  * Use Rake::FileList.
3
10
  * \#1 Removed localization monkey patch. mongoid >= 3.0.10 is now required!
data/README.md CHANGED
@@ -84,7 +84,7 @@ gem 'mongoid-undo'
84
84
 
85
85
  (The MIT license)
86
86
 
87
- Copyright (c) 2012 - 2013 Mario Uher
87
+ Copyright (c) 2012 - 2014 Mario Uher
88
88
 
89
89
  Permission is hereby granted, free of charge, to any person obtaining
90
90
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rake/testtask'
2
2
 
3
3
  Rake::TestTask.new do |t|
4
- t.test_files = FileList['spec/**/*_spec.rb']
4
+ t.pattern = 'test/*_test.rb'
5
5
  end
6
6
 
7
7
  task default: :test
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Undo
3
- VERSION = '0.6.0'
3
+ VERSION = '0.7.0'
4
4
  end
5
5
  end
data/test/mongoid.yml ADDED
@@ -0,0 +1,8 @@
1
+ test:
2
+ sessions:
3
+ default:
4
+ database: mongoid_undo_test
5
+ hosts:
6
+ - localhost:27017
7
+ options:
8
+ consistency: :strong
@@ -0,0 +1,11 @@
1
+ $: << File.expand_path('../../lib', __FILE__)
2
+ require 'minitest/autorun'
3
+ require 'minitest/pride'
4
+
5
+ require 'mongoid/undo'
6
+
7
+ Mongoid.load!(File.expand_path('../mongoid.yml', __FILE__), 'test')
8
+
9
+ class Minitest::Test
10
+ alias_method :assert_not, :refute
11
+ end
data/test/undo_test.rb ADDED
@@ -0,0 +1,90 @@
1
+ require_relative 'test_helper'
2
+
3
+ class Document
4
+ include Mongoid::Document
5
+ include Mongoid::Undo
6
+
7
+ field :name, type: String
8
+ end
9
+
10
+ class Localized
11
+ include Mongoid::Document
12
+ include Mongoid::Undo
13
+
14
+ field :language, localize: true, type: String
15
+ end
16
+
17
+ class UndoTest < Minitest::Test
18
+ def test_create
19
+ document = Document.create(name: 'foo')
20
+ assert_equal :create, document.action
21
+ assert_equal 1, document.version
22
+ assert document.persisted?
23
+
24
+ document.undo
25
+ assert_equal :create, document.action
26
+ assert_equal 1, document.version
27
+ assert_not document.persisted?
28
+
29
+ document.redo
30
+ assert_equal :create, document.action
31
+ assert_equal 1, document.version
32
+ assert document.persisted?
33
+ end
34
+
35
+
36
+ def test_update
37
+ document = Document.create(name: 'foo')
38
+
39
+ document.update_attributes name: 'bar'
40
+ assert_equal :update, document.action
41
+ assert_equal 2, document.version
42
+ assert_equal 'bar', document.name
43
+
44
+ document.undo
45
+ assert_equal :update, document.action
46
+ assert_equal 3, document.version
47
+ assert_equal 'foo', document.name
48
+
49
+ document.redo
50
+ assert_equal :update, document.action
51
+ assert_equal 4, document.version
52
+ assert_equal 'bar', document.name
53
+ end
54
+
55
+
56
+ def test_destroy
57
+ document = Document.create(name: 'foo')
58
+
59
+ document.destroy
60
+ assert_equal :destroy, document.action
61
+ assert_not document.persisted?
62
+
63
+ document.undo
64
+ assert_equal :destroy, document.action
65
+ assert document.persisted?
66
+
67
+ document.redo
68
+ assert_equal :destroy, document.action
69
+ assert_not document.persisted?
70
+ end
71
+
72
+
73
+ def test_redo_equals_to_undo
74
+ document = Document.create(name: 'foo')
75
+
76
+ assert_equal document.method(:undo), document.method(:redo)
77
+ end
78
+
79
+
80
+ def test_localized_attributes
81
+ document = Localized.create(language: 'English')
82
+
83
+ document.update_attributes language: 'English Updated'
84
+ document.undo
85
+ assert_equal 'English', document.language
86
+
87
+ document.redo
88
+ assert_equal 'English Updated', document.language
89
+ end
90
+ end
metadata CHANGED
@@ -1,35 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-undo
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.6.0
4
+ version: 0.7.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mario Uher
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-15 00:00:00.000000000 Z
11
+ date: 2014-02-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- prerelease: false
16
- version_requirements: !ruby/object:Gem::Requirement
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
17
  - - ! '>='
19
18
  - !ruby/object:Gem::Version
20
19
  version: '0'
21
- none: false
22
20
  type: :runtime
23
- name: activesupport
24
- requirement: !ruby/object:Gem::Requirement
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
25
23
  requirements:
26
24
  - - ! '>='
27
25
  - !ruby/object:Gem::Version
28
26
  version: '0'
29
- none: false
30
27
  - !ruby/object:Gem::Dependency
31
- prerelease: false
32
- version_requirements: !ruby/object:Gem::Requirement
28
+ name: mongoid
29
+ requirement: !ruby/object:Gem::Requirement
33
30
  requirements:
34
31
  - - ! '>='
35
32
  - !ruby/object:Gem::Version
@@ -37,10 +34,9 @@ dependencies:
37
34
  - - <
38
35
  - !ruby/object:Gem::Version
39
36
  version: '4.0'
40
- none: false
41
37
  type: :runtime
42
- name: mongoid
43
- requirement: !ruby/object:Gem::Requirement
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
44
40
  requirements:
45
41
  - - ! '>='
46
42
  - !ruby/object:Gem::Version
@@ -48,7 +44,6 @@ dependencies:
48
44
  - - <
49
45
  - !ruby/object:Gem::Version
50
46
  version: '4.0'
51
- none: false
52
47
  description: mongoid-undo provides a super simple and easy to use undo system for
53
48
  Mongoid apps.
54
49
  email: uher.mario@gmail.com
@@ -64,12 +59,12 @@ files:
64
59
  - lib/mongoid/undo.rb
65
60
  - lib/mongoid/undo/version.rb
66
61
  - mongoid-undo.gemspec
67
- - spec/spec_helper.rb
68
- - spec/support/connection.rb
69
- - spec/support/document.rb
70
- - spec/undo_spec.rb
62
+ - test/mongoid.yml
63
+ - test/test_helper.rb
64
+ - test/undo_test.rb
71
65
  homepage: https://github.com/haihappen/mongoid-undo
72
66
  licenses: []
67
+ metadata: {}
73
68
  post_install_message:
74
69
  rdoc_options: []
75
70
  require_paths:
@@ -79,17 +74,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
74
  - - ! '>='
80
75
  - !ruby/object:Gem::Version
81
76
  version: '0'
82
- none: false
83
77
  required_rubygems_version: !ruby/object:Gem::Requirement
84
78
  requirements:
85
79
  - - ! '>='
86
80
  - !ruby/object:Gem::Version
87
81
  version: '0'
88
- none: false
89
82
  requirements: []
90
83
  rubyforge_project:
91
- rubygems_version: 1.8.25
84
+ rubygems_version: 2.1.11
92
85
  signing_key:
93
- specification_version: 3
86
+ specification_version: 4
94
87
  summary: Super simple undo for your Mongoid app.
95
88
  test_files: []
data/spec/spec_helper.rb DELETED
@@ -1,11 +0,0 @@
1
- $: << File.expand_path('../../lib', __FILE__)
2
-
3
- require 'minitest/autorun'
4
- require 'minitest/pride'
5
- require 'minitest/spec'
6
-
7
- require 'mongoid/undo'
8
-
9
- # Load support *.rb files in ./support
10
- Dir[File.expand_path('../support/*.rb', __FILE__)].each { |file| require_relative file }
11
-
@@ -1,3 +0,0 @@
1
- Mongoid.configure do |config|
2
- config.connect_to('mongoid_undo_test')
3
- end
@@ -1,13 +0,0 @@
1
- class Document
2
- include Mongoid::Document
3
- include Mongoid::Undo
4
-
5
- field :name, type: String
6
- end
7
-
8
- class Localized
9
- include Mongoid::Document
10
- include Mongoid::Undo
11
-
12
- field :language, localize: true
13
- end
data/spec/undo_spec.rb DELETED
@@ -1,173 +0,0 @@
1
- require File.expand_path('../spec_helper', __FILE__)
2
-
3
- describe Mongoid::Undo do
4
- subject { Document.new(name: 'foo') }
5
-
6
-
7
- describe 'creating' do
8
- before { subject.save }
9
-
10
-
11
- it 'sets action to :create' do
12
- subject.action.must_equal :create
13
- end
14
-
15
-
16
- describe 'undoing' do
17
- before { subject.undo }
18
-
19
-
20
- it 'deletes' do
21
- subject.persisted?.wont_equal true
22
- end
23
-
24
-
25
- it 'keeps :create action' do
26
- subject.action.must_equal :create
27
- end
28
-
29
-
30
- describe 'redoing' do
31
- before { subject.redo }
32
-
33
-
34
- it 'restores' do
35
- subject.persisted?.must_equal true
36
- end
37
-
38
-
39
- it 'keeps :create action' do
40
- subject.action.must_equal :create
41
- end
42
- end
43
- end
44
-
45
-
46
- describe 'updating' do
47
- before { subject.update_attributes(name: 'bar') }
48
-
49
-
50
- it 'sets action to :update' do
51
- subject.action.must_equal :update
52
- end
53
-
54
-
55
- describe 'undoing' do
56
- before { subject.undo }
57
-
58
-
59
- it 'retrieves' do
60
- subject.name.must_equal 'foo'
61
- end
62
-
63
-
64
- it 'saves a new version' do
65
- subject.version.must_equal 3
66
- end
67
-
68
-
69
- it 'keeps :update action' do
70
- subject.action.must_equal :update
71
- end
72
-
73
-
74
- describe 'redoing' do
75
- before { subject.redo }
76
-
77
-
78
- it 'retrieves' do
79
- subject.name.must_equal 'bar'
80
- end
81
-
82
-
83
- it 'saves a new version' do
84
- subject.version.must_equal 4
85
- end
86
-
87
-
88
- it 'keeps :update action' do
89
- subject.action.must_equal :update
90
- end
91
- end
92
- end
93
- end
94
-
95
-
96
- describe 'destroying' do
97
- before { subject.destroy }
98
-
99
-
100
- it 'sets action to :destroy' do
101
- subject.action.must_equal :destroy
102
- end
103
-
104
-
105
- it 'marks as destroyed' do
106
- subject.persisted?.must_equal false
107
- end
108
-
109
-
110
- describe 'undoing' do
111
- before { subject.undo }
112
-
113
-
114
- it 'restores' do
115
- subject.persisted?.wont_equal false
116
- end
117
-
118
-
119
- it 'keeps :destroy action' do
120
- subject.action.must_equal :destroy
121
- end
122
-
123
-
124
- describe 'redoing' do
125
- before { subject.redo }
126
-
127
-
128
- it 'deletes' do
129
- subject.persisted?.must_equal false
130
- end
131
-
132
-
133
- it 'keeps :destroy action' do
134
- subject.action.must_equal :destroy
135
- end
136
- end
137
- end
138
- end
139
- end
140
-
141
-
142
- describe :redo do
143
- it 'is a convenient alias for undo' do
144
- subject.method(:redo).must_equal subject.method(:undo)
145
- end
146
- end
147
-
148
-
149
- describe :action do
150
- it 'is a symbol' do
151
- subject.fields['action'].options[:type].must_equal Symbol
152
- end
153
-
154
-
155
- it 'is versionless' do
156
- subject.fields['action'].options[:versioned].must_equal false
157
- end
158
- end
159
-
160
-
161
- describe 'localization' do
162
- it 'works too with localized fields' do
163
- subject = Localized.create(language: 'English')
164
-
165
- subject.update_attributes(language: 'English Updated')
166
- subject.undo
167
- subject.language.must_equal 'English'
168
-
169
- subject.redo
170
- subject.language.must_equal 'English Updated'
171
- end
172
- end
173
- end