mover 0.1.1 → 0.2.0
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/README.markdown +31 -56
- data/lib/mover.rb +71 -52
- data/require.rb +4 -8
- data/spec/db/migrate/001_create_fixtures.rb +28 -0
- data/spec/fixtures/article.rb +3 -1
- data/spec/fixtures/article_archive.rb +6 -0
- data/spec/fixtures/comment.rb +0 -1
- data/spec/fixtures/comment_archive.rb +3 -0
- data/spec/log/test.log +4967 -19176
- data/spec/mover_spec.rb +75 -0
- data/spec/spec_helper.rb +1 -9
- metadata +6 -12
- data/lib/mover/migrator.rb +0 -44
- data/lib/mover/record.rb +0 -114
- data/lib/mover/table.rb +0 -82
- data/log/development.log +0 -6
- data/spec/db/migrate/001_create_articles.rb +0 -34
- data/spec/db/migrate/002_add_permalink.rb +0 -9
- data/spec/db/migrate/003_remove_magic_columns.rb +0 -9
- data/spec/mover/migrator_spec.rb +0 -34
- data/spec/mover/record_spec.rb +0 -156
- data/spec/mover/table_spec.rb +0 -80
data/spec/mover/table_spec.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
-
|
3
|
-
describe Mover::Base::Table do
|
4
|
-
|
5
|
-
before(:all) do
|
6
|
-
$db.migrate(1)
|
7
|
-
$db.migrate(0)
|
8
|
-
$db.migrate(1)
|
9
|
-
end
|
10
|
-
|
11
|
-
describe :create_movable_table do
|
12
|
-
|
13
|
-
before(:all) do
|
14
|
-
@article_columns = connection.columns("articles").collect(&:name)
|
15
|
-
@archive_columns = connection.columns("articles_archive").collect(&:name)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should create an archive table" do
|
19
|
-
connection.table_exists?("articles_archive").should == true
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should create an archive table with the same structure as the original table" do
|
23
|
-
@article_columns.each do |col|
|
24
|
-
@archive_columns.include?(col).should == true
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe 'with options' do
|
29
|
-
|
30
|
-
before(:all) do
|
31
|
-
Article.drop_movable_table(:archive)
|
32
|
-
Article.create_movable_table(
|
33
|
-
:archive,
|
34
|
-
:columns => %w(id read),
|
35
|
-
:indexes => %w(read)
|
36
|
-
)
|
37
|
-
@archive_columns = connection.columns("articles_archive").collect(&:name)
|
38
|
-
end
|
39
|
-
|
40
|
-
after(:all) do
|
41
|
-
Article.drop_movable_table(:archive)
|
42
|
-
Article.create_movable_table(:archive)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should create the correct columns" do
|
46
|
-
@archive_columns.length.should == 2
|
47
|
-
%w(id read).each do |col|
|
48
|
-
@archive_columns.include?(col).should == true
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should create archive indexes" do
|
53
|
-
indexes = Article.send(:indexed_columns, 'articles_archive')
|
54
|
-
indexes.to_set.should == [ "read" ].to_set
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe 'without options' do
|
59
|
-
|
60
|
-
it "should create archive indexes" do
|
61
|
-
indexes = Article.send(:indexed_columns, 'articles_archive')
|
62
|
-
indexes.to_set.should == [ "id", "title" ].to_set
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe :drop_movable_table do
|
68
|
-
|
69
|
-
it "should drop the table" do
|
70
|
-
Article.drop_movable_table(:archive)
|
71
|
-
output = connection.execute(<<-SQL)
|
72
|
-
SELECT COUNT(*)
|
73
|
-
FROM information_schema.tables
|
74
|
-
WHERE table_schema = '#{Article.configurations['test']['database']}'
|
75
|
-
AND table_name = 'articles_archive';
|
76
|
-
SQL
|
77
|
-
output.fetch_row.should == ['0']
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|