acts_as_versionable 0.3.4 → 0.3.5

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.
data/CHANGELOG.rdoc CHANGED
@@ -1,4 +1,10 @@
1
- == 0.3.3
1
+ == 0.3.5
2
+
3
+ * fixed generator
4
+ * get_version
5
+
6
+ == 0.3.4
2
7
 
3
8
  * generator only rejects id & timestamp columns
4
9
  * new_from_version returns a new record from a determined version
10
+
data/README.rdoc CHANGED
@@ -52,5 +52,6 @@
52
52
  document.version => 2
53
53
  document.versions => Array(2)
54
54
  document.revert_to(1) => #<Document ...>
55
+ document.versions.get_version 2 => #<DocumentVersion ... versioned => 2>
55
56
 
56
57
  document.new_from_version(2) => #<Document ...>
@@ -1,3 +1,3 @@
1
1
  module ActsAsVersionable
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
@@ -34,6 +34,12 @@ module ActsAsVersionable
34
34
  def actual_columns
35
35
  columns.reject { |c| REJECT_COLUMNS.include?(c.name) }
36
36
  end
37
+
38
+ def get_version(version)
39
+ revision = self.find_by_versioned_as(version)
40
+ raise NoSuchVersionError, "Couldn't find #{version} version" if revision.blank?
41
+ revision
42
+ end
37
43
  end
38
44
 
39
45
  include InstanceMethods
@@ -48,7 +54,7 @@ module ActsAsVersionable
48
54
  end
49
55
 
50
56
  def revert_to(version)
51
- revision = get_version(version)
57
+ revision = versions.get_version(version)
52
58
 
53
59
  move_columns revision, self
54
60
 
@@ -58,7 +64,7 @@ module ActsAsVersionable
58
64
  end
59
65
 
60
66
  def new_from_version(version)
61
- revision = get_version(version)
67
+ revision = versions.get_version(version)
62
68
  dummy = self.class.new
63
69
 
64
70
  move_columns revision, dummy
@@ -68,7 +74,7 @@ module ActsAsVersionable
68
74
 
69
75
  private
70
76
 
71
- def get_version(version)
77
+ def _get_version(version)
72
78
  revision = versions.find_by_versioned_as(version)
73
79
  raise NoSuchVersionError, "Couldn't find #{version} version" if revision.blank?
74
80
  revision
@@ -113,6 +113,20 @@ class VersionableTest < Test::Unit::TestCase
113
113
  assert_equal dummy.body, article.body
114
114
  end
115
115
 
116
+ def test_get_version
117
+ article = Article.first
118
+ assert_not_nil article
119
+
120
+ article.update_attributes(:title => '5', :body => '5')
121
+ assert_equal 2, article.versions.count
122
+
123
+ first = article.versions[1]
124
+ one = article.versions.get_version(2)
125
+
126
+ assert_equal first.title, one.title
127
+ assert_equal first.body, one.body
128
+ end
129
+
116
130
  def test_dependent_destroy
117
131
  Article.destroy_all
118
132
  assert_equal [], ArticleVersions.all
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_versionable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: