memento 0.4.2 → 0.4.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76b7624faf71509088b847be6d9458cf957ded70
4
- data.tar.gz: a5cf8246d670739ad8f35c8aa61ac083423b424b
3
+ metadata.gz: a398d1db995dde129200972e15977dd8e7988b81
4
+ data.tar.gz: 6ead2aab247ffbe93318efc279a84ab0f4b6023e
5
5
  SHA512:
6
- metadata.gz: 92328c9544701039b73f2bc6e10e573b04d9c8ac9235ad3f296f14278fecb168109141447bd7750dff6afe4adc3e05af59d2d45f304a2b805a985ff0210800e6
7
- data.tar.gz: a02d9c4c3486015d8481084ecf50c77b0ad7f101da4214558aae8c3ae890b035844302ffe4926e292a0cb2d5538d19bc8d72146a1fb993336574cd66bd694a16
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.1...master)
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
 
@@ -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({:user => user}, :without_protection => true) : nil
24
+ self.session = user ? Memento::Session.new(:user => user) : nil
25
25
  end
26
26
 
27
27
  def stop
@@ -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, :class_name => "Memento::State", :dependent => :delete_all, :order => "id DESC"
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
 
@@ -5,7 +5,7 @@ module Memento
5
5
  belongs_to :session, :class_name => "Memento::Session"
6
6
  belongs_to :record, :polymorphic => true
7
7
 
8
- attr_accessible nil
8
+ # attr_accessible nil
9
9
 
10
10
  validates_presence_of :session
11
11
  validates_presence_of :record
@@ -1,3 +1,3 @@
1
1
  module Memento
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
@@ -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', '~> 3.2.5'
21
- s.add_dependency 'actionpack', '~> 3.2.5'
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}, :without_protection => true)
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 eql([])
21
- @session.states.create!({:action_type => "destroy", :record => Project.create!}, :without_protection => true)
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!}, :without_protection => true)
36
- @other = Memento::Session.create!({:user => @user}, :without_protection => true).states.create!({:action_type => "destroy", :record => Project.create!}, :without_protection => true)
37
- @state2 = @session.states.create!({:action_type => "update", :record => @p2 = Project.create!}, :without_protection => true)
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"]}}, :without_protection => true)
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"]}}, :without_protection => true)
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"]}}, :without_protection => true)
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!}, :without_protection => true)
113
- Memento::Session.create!({:user => @user}, :without_protection => true).states.create!({:action_type => "destroy", :record => Project.create!}, :without_protection => true)
114
- @state2 = @session.states.create!({:action_type => "update", :record => Project.create!}, :without_protection => true)
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
@@ -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}, :without_protection => true)
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}, :without_protection => true).session.should eql(@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"}, :without_protection => true).errors[:action_type].should eql(["is not included in the list"])
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}, :without_protection => true).record.should eql(@user)
26
- Memento::State.new({:record => @session}, :without_protection => true).record.should eql(@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")}, :without_protection => true )
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
@@ -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.zone_default = (Time.respond_to?(:find_zone!) && Time.find_zone!("Berlin")) || Time.__send__(:get_zone, 'Berlin') || raise("Err")
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.2
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: 2013-07-19 00:00:00.000000000 Z
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