mover 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +5 -3
- data/lib/mover.rb +38 -12
- data/require.rb +7 -1
- data/spec/Rakefile +2 -4
- data/spec/fixtures/article.rb +4 -1
- data/spec/fixtures/article_archive.rb +4 -1
- data/spec/log/test.log +1739 -0
- data/spec/mover_spec.rb +25 -0
- data/spec/spec_helper.rb +5 -2
- metadata +2 -2
data/spec/mover_spec.rb
CHANGED
@@ -2,6 +2,31 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Mover do
|
4
4
|
|
5
|
+
describe :copy_to do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
[ 1, 0, 1 ].each { |v| $db.migrate(v) }
|
9
|
+
@articles = create_records(Article)
|
10
|
+
@comments = create_records(Comment)
|
11
|
+
@articles[0].copy_to(ArticleArchive)
|
12
|
+
Article.copy_to(ArticleArchive, [ 'id = ?', 2 ])
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'should copy both articles and their associations' do
|
16
|
+
it "should copy articles" do
|
17
|
+
Article.count.should == 5
|
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
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
5
30
|
describe :move_to do
|
6
31
|
|
7
32
|
before(:each) do
|
data/spec/spec_helper.rb
CHANGED
@@ -28,13 +28,16 @@ def create_records(klass, values={})
|
|
28
28
|
klass.delete_all
|
29
29
|
(1..5).collect do |x|
|
30
30
|
klass.column_names.each do |column|
|
31
|
+
next if column == 'id'
|
31
32
|
if column == 'article_id'
|
32
33
|
values[:article_id] = x
|
33
34
|
else
|
34
35
|
values[column.intern] = "#{klass} #{x} #{column}"
|
35
36
|
end
|
36
37
|
end
|
37
|
-
|
38
|
-
|
38
|
+
record = klass.new
|
39
|
+
record.id = x
|
40
|
+
record.update_attributes(values)
|
41
|
+
record
|
39
42
|
end
|
40
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Winton Welsh
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-05-03 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|