memento 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +13 -1
- data/lib/memento.rb +1 -1
- data/lib/memento/session.rb +3 -2
- data/lib/memento/state.rb +1 -1
- data/lib/memento/version.rb +1 -1
- data/memento.gemspec +2 -2
- data/spec/memento/session_spec.rb +12 -20
- data/spec/memento/state_spec.rb +6 -17
- data/spec/spec_helper.rb +4 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a398d1db995dde129200972e15977dd8e7988b81
|
4
|
+
data.tar.gz: 6ead2aab247ffbe93318efc279a84ab0f4b6023e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2e302f650ed080fabd0807fdaeb6d73aa3d60836dec5f7ef6a5aacddca58f32191e2e66d4006a5950ca92fb79787216be1cce48d6a2d37551f16996a8ee7461
|
7
|
+
data.tar.gz: 985907459e9ec2f51a4fb847e317f5872195bdfeee31038a1ec4de8e9e2c7e5bb3dfecfa793e33460ec781d5218b68a9e54bc314396a0db396701f007a7aaa30
|
data/CHANGES.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
### dev
|
2
2
|
|
3
|
-
[full changelog](http://github.com/yolk/valvat/compare/v0.4.
|
3
|
+
[full changelog](http://github.com/yolk/valvat/compare/v0.4.3...master)
|
4
|
+
|
5
|
+
### 0.4.3 / 2014-04-07
|
6
|
+
|
7
|
+
[full changelog](http://github.com/yolk/valvat/compare/v0.4.2...v0.4.3)
|
8
|
+
|
9
|
+
* Full Rails 4 compatibility
|
10
|
+
|
11
|
+
### 0.4.2 / 2013-07-19
|
12
|
+
|
13
|
+
[full changelog](http://github.com/yolk/valvat/compare/v0.4.1...v0.4.2)
|
14
|
+
|
15
|
+
* Replaced find_by_* calls for compatibility with ActiveRecord 4.0
|
4
16
|
|
5
17
|
### 0.4.1 / 2012-11-01
|
6
18
|
|
data/lib/memento.rb
CHANGED
@@ -21,7 +21,7 @@ module Memento
|
|
21
21
|
|
22
22
|
def start(user_or_id)
|
23
23
|
user = user_or_id.is_a?(User) ? user_or_id : User.where(:id => user_or_id).first
|
24
|
-
self.session = user ? Memento::Session.new(
|
24
|
+
self.session = user ? Memento::Session.new(:user => user) : nil
|
25
25
|
end
|
26
26
|
|
27
27
|
def stop
|
data/lib/memento/session.rb
CHANGED
@@ -2,10 +2,11 @@ module Memento
|
|
2
2
|
class Session < ActiveRecord::Base
|
3
3
|
self.table_name = "memento_sessions"
|
4
4
|
|
5
|
-
has_many :states,
|
5
|
+
has_many :states, -> { order "id DESC" },
|
6
|
+
:class_name => "Memento::State", :dependent => :delete_all
|
6
7
|
belongs_to :user
|
7
8
|
|
8
|
-
attr_accessible nil
|
9
|
+
# attr_accessible nil
|
9
10
|
|
10
11
|
validates_presence_of :user
|
11
12
|
|
data/lib/memento/state.rb
CHANGED
data/lib/memento/version.rb
CHANGED
data/memento.gemspec
CHANGED
@@ -17,8 +17,8 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
|
-
s.add_dependency 'activerecord', '
|
21
|
-
s.add_dependency 'actionpack', '
|
20
|
+
s.add_dependency 'activerecord', '>= 3.2.5'
|
21
|
+
s.add_dependency 'actionpack', '>= 3.2.5'
|
22
22
|
|
23
23
|
s.add_development_dependency 'rspec', '>= 2.4.0'
|
24
24
|
s.add_development_dependency 'sqlite3', '>= 1.3.5'
|
@@ -5,7 +5,7 @@ describe Memento::Session do
|
|
5
5
|
before do
|
6
6
|
setup_db
|
7
7
|
setup_data
|
8
|
-
@session = Memento::Session.create({:user => @user}
|
8
|
+
@session = Memento::Session.create({:user => @user})
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should belong to user" do
|
@@ -17,24 +17,16 @@ describe Memento::Session do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should have_many states" do
|
20
|
-
@session.states.should
|
21
|
-
@session.states.create!({:action_type => "destroy", :record => Project.create!}
|
20
|
+
@session.states.should be_empty
|
21
|
+
@session.states.create!({:action_type => "destroy", :record => Project.create!})
|
22
22
|
@session.states.count.should eql(1)
|
23
23
|
end
|
24
24
|
|
25
|
-
it "should disallow all mass assignment" do
|
26
|
-
Memento::Session.accessible_attributes.deny?("id").should eql(true)
|
27
|
-
Memento::Session.accessible_attributes.deny?("created_at").should eql(true)
|
28
|
-
Memento::Session.accessible_attributes.deny?("updated_at").should eql(true)
|
29
|
-
Memento::Session.accessible_attributes.deny?("user_id").should eql(true)
|
30
|
-
Memento::Session.accessible_attributes.deny?("user").should eql(true)
|
31
|
-
end
|
32
|
-
|
33
25
|
context "undo" do
|
34
26
|
before do
|
35
|
-
@state1 = @session.states.create!({:action_type => "update", :record => @p1 = Project.create!}
|
36
|
-
@other = Memento::Session.create!({:user => @user}
|
37
|
-
@state2 = @session.states.create!({:action_type => "update", :record => @p2 = Project.create!}
|
27
|
+
@state1 = @session.states.create!({:action_type => "update", :record => @p1 = Project.create!})
|
28
|
+
@other = Memento::Session.create!({:user => @user}).states.create!({:action_type => "destroy", :record => Project.create!})
|
29
|
+
@state2 = @session.states.create!({:action_type => "update", :record => @p2 = Project.create!})
|
38
30
|
end
|
39
31
|
|
40
32
|
describe "and all states succeed" do
|
@@ -55,9 +47,9 @@ describe Memento::Session do
|
|
55
47
|
|
56
48
|
describe "and all states fail" do
|
57
49
|
before do
|
58
|
-
@state1.update_attributes({:record_data => {:name => ["A", "B"]}}
|
50
|
+
@state1.update_attributes({:record_data => {:name => ["A", "B"]}})
|
59
51
|
@p1.update_attributes(:name => "C")
|
60
|
-
@state2.update_attributes({:record_data => {:name => ["A", "B"]}}
|
52
|
+
@state2.update_attributes({:record_data => {:name => ["A", "B"]}})
|
61
53
|
@p2.update_attributes(:name => "C")
|
62
54
|
end
|
63
55
|
|
@@ -78,7 +70,7 @@ describe Memento::Session do
|
|
78
70
|
|
79
71
|
describe "and some states succeed, some fail" do
|
80
72
|
before do
|
81
|
-
@state1.update_attributes({:record_data => {:name => ["A", "B"]}}
|
73
|
+
@state1.update_attributes({:record_data => {:name => ["A", "B"]}})
|
82
74
|
@p1.update_attributes(:name => "C")
|
83
75
|
end
|
84
76
|
|
@@ -109,9 +101,9 @@ describe Memento::Session do
|
|
109
101
|
|
110
102
|
describe "with states" do
|
111
103
|
before do
|
112
|
-
@session.states.create!({:action_type => "destroy", :record => Project.create!}
|
113
|
-
Memento::Session.create!({:user => @user}
|
114
|
-
@state2 = @session.states.create!({:action_type => "update", :record => Project.create!}
|
104
|
+
@session.states.create!({:action_type => "destroy", :record => Project.create!})
|
105
|
+
Memento::Session.create!({:user => @user}).states.create!({:action_type => "destroy", :record => Project.create!})
|
106
|
+
@state2 = @session.states.create!({:action_type => "update", :record => Project.create!})
|
115
107
|
end
|
116
108
|
|
117
109
|
it "should destroy all states when destroyed" do
|
data/spec/memento/state_spec.rb
CHANGED
@@ -5,11 +5,11 @@ describe Memento::State do
|
|
5
5
|
before do
|
6
6
|
setup_db
|
7
7
|
setup_data
|
8
|
-
@session = Memento::Session.create({:user => @user}
|
8
|
+
@session = Memento::Session.create({:user => @user})
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should belong to session" do
|
12
|
-
Memento::State.new({:session => @session}
|
12
|
+
Memento::State.new({:session => @session}).session.should eql(@session)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should require session" do
|
@@ -18,32 +18,21 @@ describe Memento::State do
|
|
18
18
|
|
19
19
|
it "should require action_type to be one of Memento::State::RECORD_CAUSES" do
|
20
20
|
Memento::State.create.errors[:action_type].should eql(["can't be blank"])
|
21
|
-
Memento::State.create({:action_type => "move"}
|
21
|
+
Memento::State.create({:action_type => "move"}).errors[:action_type].should eql(["is not included in the list"])
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should belong to polymorphic record" do
|
25
|
-
Memento::State.new({:record => @user}
|
26
|
-
Memento::State.new({:record => @session}
|
25
|
+
Memento::State.new({:record => @user}).record.should eql(@user)
|
26
|
+
Memento::State.new({:record => @session}).record.should eql(@session)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should require record" do
|
30
30
|
Memento::State.create.errors[:record].should eql(["can't be blank"])
|
31
31
|
end
|
32
32
|
|
33
|
-
it "should disallow all mass assignment" do
|
34
|
-
Memento::State.accessible_attributes.deny?("id").should eql(true)
|
35
|
-
Memento::State.accessible_attributes.deny?("created_at").should eql(true)
|
36
|
-
Memento::State.accessible_attributes.deny?("updated_at").should eql(true)
|
37
|
-
Memento::State.accessible_attributes.deny?("session_id").should eql(true)
|
38
|
-
Memento::State.accessible_attributes.deny?("session").should eql(true)
|
39
|
-
Memento::State.accessible_attributes.deny?("record_id").should eql(true)
|
40
|
-
Memento::State.accessible_attributes.deny?("record_type").should eql(true)
|
41
|
-
Memento::State.accessible_attributes.deny?("record").should eql(true)
|
42
|
-
end
|
43
|
-
|
44
33
|
describe "valid State" do
|
45
34
|
before do
|
46
|
-
@state = @session.states.create!({:action_type => "destroy", :record => @project = Project.create(:name => "A")}
|
35
|
+
@state = @session.states.create!({:action_type => "destroy", :record => @project = Project.create(:name => "A")} )
|
47
36
|
end
|
48
37
|
|
49
38
|
it "should give back Memento::Result on undo" do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
require 'active_support'
|
2
|
+
require 'active_support/time'
|
2
3
|
require 'active_record'
|
3
4
|
require 'action_controller'
|
4
5
|
require 'rspec'
|
5
6
|
|
7
|
+
I18n.enforce_available_locales = false
|
8
|
+
|
6
9
|
# Initialize time_zones from rails
|
7
|
-
Time.
|
10
|
+
Time.zone = "Berlin"
|
8
11
|
ActiveRecord::Base.time_zone_aware_attributes = true
|
9
12
|
ActiveRecord::Base.default_timezone = :utc
|
10
13
|
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memento
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yolk Sebastian Munz & Julia Soergel GbR
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.2.5
|
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
26
|
version: 3.2.5
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: actionpack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 3.2.5
|
34
34
|
type: :runtime
|
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: 3.2.5
|
41
41
|
- !ruby/object:Gem::Dependency
|