mover 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/lib/mover.rb +48 -7
  2. data/require.rb +1 -1
  3. data/spec/log/test.log +11527 -6294
  4. data/spec/mover_spec.rb +19 -12
  5. metadata +20 -9
data/spec/mover_spec.rb CHANGED
@@ -9,22 +9,29 @@ describe Mover do
9
9
  @articles = create_records(Article)
10
10
  @comments = create_records(Comment)
11
11
  @articles[0].copy_to(ArticleArchive)
12
- Article.copy_to(ArticleArchive, [ 'id = ?', 2 ])
13
12
  end
14
13
 
15
14
  describe 'should copy both articles and their associations' do
16
15
  it "should copy articles" do
16
+ Article.copy_to(ArticleArchive, [ 'id = ? OR id = ? OR id = ?', 1, 2, 3 ])
17
17
  Article.count.should == 5
18
18
  Comment.count.should == 5
19
- ArticleArchive.count.should == 2
20
- CommentArchive.count.should == 2
21
- Article.find_by_id(1).nil?.should == false
22
- Comment.find_by_id(2).nil?.should == false
23
- ArticleArchive.find_by_id(1).nil?.should == false
24
- CommentArchive.find_by_id(2).nil?.should == false
19
+ ArticleArchive.count.should == 3
20
+ CommentArchive.count.should == 3
25
21
  end
26
22
  end
27
23
 
24
+ describe 'should overwrite first copy if copied twice' do
25
+ it "should copy articles" do
26
+ Article.find(1).update_attributes(:title => 'foobar edited')
27
+ Article.copy_to(ArticleArchive, [ 'id = ? OR id = ? OR id = ?', 1, 2, 3 ])
28
+ ArticleArchive.find(1).title.should == 'foobar edited'
29
+ Article.count.should == 5
30
+ Comment.count.should == 5
31
+ ArticleArchive.count.should == 3
32
+ CommentArchive.count.should == 3
33
+ end
34
+ end
28
35
  end
29
36
 
30
37
  describe :move_to do
@@ -38,7 +45,7 @@ describe Mover do
38
45
  end
39
46
 
40
47
  describe 'move records' do
41
-
48
+
42
49
  it "should move both articles and their associations" do
43
50
  Article.count.should == 3
44
51
  Comment.count.should == 3
@@ -55,19 +62,19 @@ describe Mover do
55
62
  comments.length.should == 1
56
63
  comments.first.id.should == 2
57
64
  end
58
-
65
+
59
66
  it "should assign moved_at" do
60
67
  ArticleArchive.find_by_id(1).moved_at.utc.to_s.should == Time.now.utc.to_s
61
68
  end
62
69
  end
63
70
 
64
71
  describe 'move records back' do
65
-
72
+
66
73
  before(:each) do
67
74
  ArticleArchive.find(1).move_to(Article)
68
75
  ArticleArchive.move_to(Article, [ 'id = ?', 2 ])
69
76
  end
70
-
77
+
71
78
  it "should move both articles and their associations" do
72
79
  Article.count.should == 5
73
80
  Comment.count.should == 5
@@ -91,7 +98,7 @@ describe Mover do
91
98
  it "should return an id" do
92
99
  Article.reserve_id.class.should == Fixnum
93
100
  end
94
-
101
+
95
102
  it "should delete the record" do
96
103
  id = Article.reserve_id
97
104
  Article.find_by_id(id).should == nil
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 2
9
+ version: 0.2.2
5
10
  platform: ruby
6
11
  authors:
7
12
  - Winton Welsh
@@ -9,19 +14,23 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-05-03 00:00:00 -07:00
17
+ date: 2010-05-04 00:00:00 -07:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: require
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - "="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 2
30
+ - 6
23
31
  version: 0.2.6
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  description:
26
35
  email: mail@wintoni.us
27
36
  executables: []
@@ -61,18 +70,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
61
70
  requirements:
62
71
  - - ">="
63
72
  - !ruby/object:Gem::Version
73
+ segments:
74
+ - 0
64
75
  version: "0"
65
- version:
66
76
  required_rubygems_version: !ruby/object:Gem::Requirement
67
77
  requirements:
68
78
  - - ">="
69
79
  - !ruby/object:Gem::Version
80
+ segments:
81
+ - 0
70
82
  version: "0"
71
- version:
72
83
  requirements: []
73
84
 
74
85
  rubyforge_project:
75
- rubygems_version: 1.3.5
86
+ rubygems_version: 1.3.6
76
87
  signing_key:
77
88
  specification_version: 3
78
89
  summary: Move ActiveRecord records across tables like it ain't no thang