partitioned 1.3.4 → 1.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.
- checksums.yaml +7 -0
- data/.travis.yml +15 -0
- data/lib/partitioned/by_daily_time_field.rb +1 -1
- data/lib/partitioned/version.rb +1 -1
- data/lib/partitioned.rb +2 -1
- data/partitioned.gemspec +3 -2
- data/spec/monkey_patch_posgres_spec.rb +16 -16
- data/spec/partitioned/by_created_at_spec.rb +2 -2
- data/spec/partitioned/by_daily_time_field_spec.rb +7 -7
- data/spec/partitioned/by_foreign_key_spec.rb +7 -7
- data/spec/partitioned/by_id_spec.rb +6 -6
- data/spec/partitioned/by_integer_field_spec.rb +12 -12
- data/spec/partitioned/by_monthly_time_field_spec.rb +7 -7
- data/spec/partitioned/by_time_field_spec.rb +22 -22
- data/spec/partitioned/by_weekly_time_field_spec.rb +7 -7
- data/spec/partitioned/by_yearly_time_field_spec.rb +7 -7
- data/spec/partitioned/multi_level/configurator/dsl_spec.rb +9 -8
- data/spec/partitioned/multi_level/configurator/reader_spec.rb +14 -14
- data/spec/partitioned/partitioned_base/configurator/dsl_spec.rb +39 -38
- data/spec/partitioned/partitioned_base/configurator/reader_spec.rb +48 -48
- data/spec/partitioned/partitioned_base/sql_adapter_spec.rb +15 -15
- data/spec/partitioned/partitioned_base_spec.rb +20 -20
- data/spec/spec_helper.rb +11 -1
- data/spec/support/shared_example_spec_helper_for_integer_key.rb +19 -19
- data/spec/support/shared_example_spec_helper_for_time_key.rb +20 -20
- metadata +37 -36
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bb273afc943e89b665d5102b95da5edb8a08ece3
|
4
|
+
data.tar.gz: 82acc9f8f6adf56e2f9819aa2a6162f83f932183
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fc7a3eb02f86a030908f2bded67c3ad0569b582b884f4226e5385f43866827fec51d671f2f06b2a1768df52fbafb0be3ce99dc8e3acc0cd95621ec3f02b0e796
|
7
|
+
data.tar.gz: 65007a35629ed9f656e16d29e97e07b4d0985fb6ada1d1a2913d5380ce2e4add70f46759af5a4f8141956e857aa4542fefeeec49b5b348f69e86f6edcdd1dbf3
|
data/.travis.yml
ADDED
@@ -12,7 +12,7 @@ module Partitioned
|
|
12
12
|
# @param [Time] time_value the time value to normalize
|
13
13
|
# @return [Time] the value normalized
|
14
14
|
def self.partition_normalize_key_value(time_value)
|
15
|
-
return time_value.at_beginning_of_day
|
15
|
+
return time_value.at_beginning_of_day.to_date
|
16
16
|
end
|
17
17
|
|
18
18
|
#
|
data/lib/partitioned/version.rb
CHANGED
data/lib/partitioned.rb
CHANGED
@@ -16,6 +16,7 @@ require 'partitioned/by_time_field'
|
|
16
16
|
require 'partitioned/by_yearly_time_field'
|
17
17
|
require 'partitioned/by_monthly_time_field'
|
18
18
|
require 'partitioned/by_weekly_time_field'
|
19
|
+
require 'partitioned/by_daily_time_field'
|
19
20
|
require 'partitioned/by_created_at'
|
20
21
|
require 'partitioned/by_integer_field'
|
21
22
|
require 'partitioned/by_id'
|
@@ -25,4 +26,4 @@ require 'partitioned/multi_level'
|
|
25
26
|
require 'partitioned/multi_level/configurator/data'
|
26
27
|
require 'partitioned/multi_level/configurator/dsl'
|
27
28
|
require 'partitioned/multi_level/configurator/reader'
|
28
|
-
require 'partitioned/multi_level/partition_manager'
|
29
|
+
require 'partitioned/multi_level/partition_manager'
|
data/partitioned.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_dependency 'pg'
|
23
23
|
s.add_dependency 'bulk_data_methods'
|
24
24
|
s.add_dependency 'activerecord-redshift-adapter'
|
25
|
-
s.
|
26
|
-
s.add_development_dependency '
|
25
|
+
s.add_dependency 'activerecord', '~> 3.0'
|
26
|
+
s.add_development_dependency 'rails', '~> 3.2.8'
|
27
|
+
s.add_development_dependency 'rspec-rails', '~> 3.0'
|
27
28
|
end
|
@@ -8,8 +8,8 @@ module ActiveRecord::ConnectionAdapters
|
|
8
8
|
describe "check_constraint" do
|
9
9
|
|
10
10
|
it "returns an array of constraints" do
|
11
|
-
TableDefinition.new(nil).check_constraint("( id >= 0 and id < 10 )").
|
12
|
-
first.to_sql.
|
11
|
+
expect(TableDefinition.new(nil).check_constraint("( id >= 0 and id < 10 )").
|
12
|
+
first.to_sql).to eq "CHECK (( id >= 0 and id < 10 ))"
|
13
13
|
end # returns an array of constraints
|
14
14
|
|
15
15
|
end # check_constraint
|
@@ -45,12 +45,12 @@ module ActiveRecord::ConnectionAdapters
|
|
45
45
|
describe "next_sequence_value" do
|
46
46
|
|
47
47
|
it "returns next_sequence_value" do
|
48
|
-
ActiveRecord::Base.connection.next_sequence_value(Employee.sequence_name).
|
48
|
+
expect(ActiveRecord::Base.connection.next_sequence_value(Employee.sequence_name)).to eq 1
|
49
49
|
ActiveRecord::Base.connection.execute <<-SQL
|
50
50
|
insert into employees(name, company_id) values ('Nikita', 1);
|
51
51
|
SQL
|
52
|
-
ActiveRecord::Base.connection.next_sequence_value(Employee.sequence_name).
|
53
|
-
ActiveRecord::Base.connection.next_sequence_value(Employee.sequence_name).
|
52
|
+
expect(ActiveRecord::Base.connection.next_sequence_value(Employee.sequence_name)).to eq 3
|
53
|
+
expect(ActiveRecord::Base.connection.next_sequence_value(Employee.sequence_name)).to eq 4
|
54
54
|
end
|
55
55
|
|
56
56
|
end # next_sequence_value
|
@@ -58,7 +58,7 @@ module ActiveRecord::ConnectionAdapters
|
|
58
58
|
describe "next_sequence_values" do
|
59
59
|
|
60
60
|
it "returns five next_sequence_values" do
|
61
|
-
ActiveRecord::Base.connection.next_sequence_values(Employee.sequence_name, 5).
|
61
|
+
expect(ActiveRecord::Base.connection.next_sequence_values(Employee.sequence_name, 5)).to eq [1, 2, 3, 4, 5]
|
62
62
|
end
|
63
63
|
|
64
64
|
end # next_sequence_values
|
@@ -71,7 +71,7 @@ module ActiveRecord::ConnectionAdapters
|
|
71
71
|
|
72
72
|
it "created schema" do
|
73
73
|
ActiveRecord::Base.connection.create_schema("employees_partitions")
|
74
|
-
check_existence_schema.values.
|
74
|
+
expect(check_existence_schema.values).not_to be_blank
|
75
75
|
end # created schema
|
76
76
|
|
77
77
|
end # when call without options
|
@@ -82,7 +82,7 @@ module ActiveRecord::ConnectionAdapters
|
|
82
82
|
create_new_schema
|
83
83
|
default_schema = check_existence_schema
|
84
84
|
ActiveRecord::Base.connection.create_schema("employees_partitions", :unless_exists => true)
|
85
|
-
default_schema.values.
|
85
|
+
expect(default_schema.values).to eq check_existence_schema.values
|
86
86
|
end # returns nil if schema exist
|
87
87
|
|
88
88
|
end # when call with options unless_exists = true and schema with this name already exist
|
@@ -91,10 +91,10 @@ module ActiveRecord::ConnectionAdapters
|
|
91
91
|
|
92
92
|
it "raises ActiveRecord::StatementInvalid" do
|
93
93
|
create_new_schema
|
94
|
-
lambda {
|
94
|
+
expect(lambda {
|
95
95
|
ActiveRecord::Base.
|
96
96
|
connection.create_schema("employees_partitions", :unless_exists => false)
|
97
|
-
}.
|
97
|
+
}).to raise_error(ActiveRecord::StatementInvalid)
|
98
98
|
end # raises ActiveRecord::StatementInvalid
|
99
99
|
|
100
100
|
end # when call with options unless_exists = false and schema with this name already exist
|
@@ -108,7 +108,7 @@ module ActiveRecord::ConnectionAdapters
|
|
108
108
|
it "deleted schema" do
|
109
109
|
create_new_schema
|
110
110
|
ActiveRecord::Base.connection.drop_schema("employees_partitions")
|
111
|
-
check_existence_schema.values.
|
111
|
+
expect(check_existence_schema.values).to be_blank
|
112
112
|
end
|
113
113
|
|
114
114
|
end # when call without options
|
@@ -117,7 +117,7 @@ module ActiveRecord::ConnectionAdapters
|
|
117
117
|
|
118
118
|
it "deleted schema" do
|
119
119
|
ActiveRecord::Base.connection.drop_schema("employees_partitions", :if_exists => true)
|
120
|
-
check_existence_schema.values.
|
120
|
+
expect(check_existence_schema.values).to be_blank
|
121
121
|
end
|
122
122
|
|
123
123
|
end # when call with options if_exist = true and schema with this name don't exist
|
@@ -125,10 +125,10 @@ module ActiveRecord::ConnectionAdapters
|
|
125
125
|
context "when call with options if_exist = false and schema with this name don't exist" do
|
126
126
|
|
127
127
|
it "raises ActiveRecord::StatementInvalid" do
|
128
|
-
lambda {
|
128
|
+
expect(lambda {
|
129
129
|
ActiveRecord::Base.
|
130
130
|
connection.drop_schema("employees_partitions", :if_exists => false)
|
131
|
-
}.
|
131
|
+
}).to raise_error(ActiveRecord::StatementInvalid)
|
132
132
|
end
|
133
133
|
|
134
134
|
end # when call with options if_exist = false and schema with this name don't exist
|
@@ -141,7 +141,7 @@ module ActiveRecord::ConnectionAdapters
|
|
141
141
|
create table employees_partitions.temp();
|
142
142
|
SQL
|
143
143
|
ActiveRecord::Base.connection.drop_schema("employees_partitions", :cascade => true)
|
144
|
-
check_existence_schema.values.
|
144
|
+
expect(check_existence_schema.values).to be_blank
|
145
145
|
end
|
146
146
|
|
147
147
|
end # when call with option cascade = true
|
@@ -166,7 +166,7 @@ module ActiveRecord::ConnectionAdapters
|
|
166
166
|
SELECT constraint_type FROM information_schema.table_constraints
|
167
167
|
WHERE table_name = 'temp' AND constraint_name = 'temp_company_id_fkey';
|
168
168
|
SQL
|
169
|
-
result.values.first.
|
169
|
+
expect(result.values.first).to eq ["FOREIGN KEY"]
|
170
170
|
end
|
171
171
|
|
172
172
|
end # add_foreign_key
|
@@ -42,7 +42,7 @@ module Partitioned
|
|
42
42
|
describe "model is abstract class" do
|
43
43
|
|
44
44
|
it "returns true" do
|
45
|
-
class_by_created_at.abstract_class.
|
45
|
+
expect(class_by_created_at.abstract_class).to be_truthy
|
46
46
|
end
|
47
47
|
|
48
48
|
end # model is abstract class
|
@@ -50,7 +50,7 @@ module Partitioned
|
|
50
50
|
describe "#partition_time_field" do
|
51
51
|
|
52
52
|
it "returns :created_at" do
|
53
|
-
class_by_created_at.partition_time_field.
|
53
|
+
expect(class_by_created_at.partition_time_field).to eq(:created_at)
|
54
54
|
end
|
55
55
|
|
56
56
|
end # #partition_time_field
|
@@ -46,7 +46,7 @@ module Partitioned
|
|
46
46
|
describe "model is abstract class" do
|
47
47
|
|
48
48
|
it "returns true" do
|
49
|
-
class_by_daily_time_field.abstract_class.
|
49
|
+
expect(class_by_daily_time_field.abstract_class).to be_truthy
|
50
50
|
end
|
51
51
|
|
52
52
|
end # model is abstract class
|
@@ -54,9 +54,9 @@ module Partitioned
|
|
54
54
|
describe "#partition_normalize_key_value" do
|
55
55
|
|
56
56
|
it "returns the beginning of the day" do
|
57
|
-
class_by_daily_time_field.
|
58
|
-
partition_normalize_key_value(Date.parse('2011-01-05')).
|
59
|
-
|
57
|
+
expect(class_by_daily_time_field.
|
58
|
+
partition_normalize_key_value(Date.parse('2011-01-05'))).
|
59
|
+
to eq(Date.parse('2011-01-05'))
|
60
60
|
end
|
61
61
|
|
62
62
|
end # #partition_normalize_key_value
|
@@ -64,7 +64,7 @@ module Partitioned
|
|
64
64
|
describe "#partition_table_size" do
|
65
65
|
|
66
66
|
it "returns 1.day" do
|
67
|
-
class_by_daily_time_field.partition_table_size.
|
67
|
+
expect(class_by_daily_time_field.partition_table_size).to eq(1.day)
|
68
68
|
end
|
69
69
|
|
70
70
|
end # #partition_table_size
|
@@ -78,7 +78,7 @@ module Partitioned
|
|
78
78
|
context "checks data in the base_name is Proc" do
|
79
79
|
|
80
80
|
it "returns Proc" do
|
81
|
-
data.base_name.
|
81
|
+
expect(data.base_name).to be_is_a Proc
|
82
82
|
end
|
83
83
|
|
84
84
|
end # checks data in the base_name is Proc
|
@@ -86,7 +86,7 @@ module Partitioned
|
|
86
86
|
context "checks data in the base_name" do
|
87
87
|
|
88
88
|
it "returns base_name" do
|
89
|
-
data.base_name.call(@employee, Date.parse('2011-01-05')).
|
89
|
+
expect(data.base_name.call(@employee, Date.parse('2011-01-05'))).to eq("20110105")
|
90
90
|
end
|
91
91
|
|
92
92
|
end # checks data in the base_name
|
@@ -41,7 +41,7 @@ module Partitioned
|
|
41
41
|
describe "model is abstract class" do
|
42
42
|
|
43
43
|
it "returns true" do
|
44
|
-
class_by_foreign_key.abstract_class.
|
44
|
+
expect(class_by_foreign_key.abstract_class).to be_truthy
|
45
45
|
end
|
46
46
|
|
47
47
|
end # model is abstract class
|
@@ -49,9 +49,9 @@ module Partitioned
|
|
49
49
|
describe "#partition_foreign_key" do
|
50
50
|
|
51
51
|
it "raises MethodNotImplemented" do
|
52
|
-
|
52
|
+
expect {
|
53
53
|
class_by_foreign_key.partition_foreign_key
|
54
|
-
}.
|
54
|
+
}.to raise_error(MethodNotImplemented)
|
55
55
|
end
|
56
56
|
|
57
57
|
end # #partition_foreign_key
|
@@ -61,7 +61,7 @@ module Partitioned
|
|
61
61
|
context "checks data in the foreign_keys is Proc" do
|
62
62
|
|
63
63
|
it "returns Proc" do
|
64
|
-
class_by_foreign_key.configurator_dsl.data.foreign_keys.first.
|
64
|
+
expect(class_by_foreign_key.configurator_dsl.data.foreign_keys.first).to be_is_a Proc
|
65
65
|
end
|
66
66
|
|
67
67
|
end # checks data in the foreign_keys is Proc
|
@@ -73,15 +73,15 @@ module Partitioned
|
|
73
73
|
end
|
74
74
|
|
75
75
|
it "returns referencing_field" do
|
76
|
-
proc.referencing_field.
|
76
|
+
expect(proc.referencing_field).to eq(:company_id)
|
77
77
|
end
|
78
78
|
|
79
79
|
it "returns referenced_field" do
|
80
|
-
proc.referenced_field.
|
80
|
+
expect(proc.referenced_field).to eq(:id)
|
81
81
|
end
|
82
82
|
|
83
83
|
it "returns referencing_field" do
|
84
|
-
proc.referenced_table.
|
84
|
+
expect(proc.referenced_table).to eq("companies")
|
85
85
|
end
|
86
86
|
|
87
87
|
end # checks if there is data in the foreign_keys
|
@@ -41,7 +41,7 @@ module Partitioned
|
|
41
41
|
describe "model is abstract class" do
|
42
42
|
|
43
43
|
it "returns true" do
|
44
|
-
class_by_id.abstract_class.
|
44
|
+
expect(class_by_id.abstract_class).to be_truthy
|
45
45
|
end
|
46
46
|
|
47
47
|
end # model is abstract class
|
@@ -51,7 +51,7 @@ module Partitioned
|
|
51
51
|
context "is :id set as a primary_key" do
|
52
52
|
|
53
53
|
it "returns true" do
|
54
|
-
class_by_id.prefetch_primary_key
|
54
|
+
expect(class_by_id.prefetch_primary_key?).to be_truthy
|
55
55
|
end
|
56
56
|
|
57
57
|
end # is :id set as a primary_key
|
@@ -61,7 +61,7 @@ module Partitioned
|
|
61
61
|
describe "#partition_table_size" do
|
62
62
|
|
63
63
|
it "returns 10000000" do
|
64
|
-
class_by_id.partition_table_size.
|
64
|
+
expect(class_by_id.partition_table_size).to eq(10000000)
|
65
65
|
end
|
66
66
|
|
67
67
|
end # #partition_table_size
|
@@ -69,7 +69,7 @@ module Partitioned
|
|
69
69
|
describe "#partition_integer_field" do
|
70
70
|
|
71
71
|
it "returns :id" do
|
72
|
-
class_by_id.partition_integer_field.
|
72
|
+
expect(class_by_id.partition_integer_field).to eq(:id)
|
73
73
|
end
|
74
74
|
|
75
75
|
end # #partition_integer_field
|
@@ -79,11 +79,11 @@ module Partitioned
|
|
79
79
|
context "checks if there is data in the indexes field" do
|
80
80
|
|
81
81
|
it "returns :id" do
|
82
|
-
class_by_id.configurator_dsl.data.indexes.first.field.
|
82
|
+
expect(class_by_id.configurator_dsl.data.indexes.first.field).to eq(:id)
|
83
83
|
end
|
84
84
|
|
85
85
|
it "returns { :unique => true }" do
|
86
|
-
class_by_id.configurator_dsl.data.indexes.first.options.
|
86
|
+
expect(class_by_id.configurator_dsl.data.indexes.first.options).to eq({ :unique => true })
|
87
87
|
end
|
88
88
|
|
89
89
|
end # checks if there is data in the indexes field
|
@@ -41,7 +41,7 @@ module Partitioned
|
|
41
41
|
describe "model is abstract class" do
|
42
42
|
|
43
43
|
it "returns true" do
|
44
|
-
class_by_integer_field.abstract_class.
|
44
|
+
expect(class_by_integer_field.abstract_class).to be_truthy
|
45
45
|
end
|
46
46
|
|
47
47
|
end # model is abstract class
|
@@ -49,7 +49,7 @@ module Partitioned
|
|
49
49
|
describe "#partition_table_size" do
|
50
50
|
|
51
51
|
it "returns 1" do
|
52
|
-
class_by_integer_field.partition_table_size.
|
52
|
+
expect(class_by_integer_field.partition_table_size).to eq(1)
|
53
53
|
end
|
54
54
|
|
55
55
|
end # #partition_table_size
|
@@ -57,9 +57,9 @@ module Partitioned
|
|
57
57
|
describe "#partition_integer_field" do
|
58
58
|
|
59
59
|
it "raises MethodNotImplemented" do
|
60
|
-
|
60
|
+
expect {
|
61
61
|
class_by_integer_field.partition_integer_field
|
62
|
-
}.
|
62
|
+
}.to raise_error(MethodNotImplemented)
|
63
63
|
end
|
64
64
|
|
65
65
|
end # #partition_integer_field
|
@@ -69,7 +69,7 @@ module Partitioned
|
|
69
69
|
context "when call method with param equal five" do
|
70
70
|
|
71
71
|
it "returns 5" do
|
72
|
-
class_by_integer_field.partition_normalize_key_value(5).
|
72
|
+
expect(class_by_integer_field.partition_normalize_key_value(5)).to eq(5)
|
73
73
|
end
|
74
74
|
|
75
75
|
end
|
@@ -85,7 +85,7 @@ module Partitioned
|
|
85
85
|
context "checks data in the on_field is Proc" do
|
86
86
|
|
87
87
|
it "returns Proc" do
|
88
|
-
data.on_field.
|
88
|
+
expect(data.on_field).to be_is_a Proc
|
89
89
|
end
|
90
90
|
|
91
91
|
end # checks data in the on_field is Proc
|
@@ -93,7 +93,7 @@ module Partitioned
|
|
93
93
|
context "checks data in the check_constraint is Proc" do
|
94
94
|
|
95
95
|
it "returns Proc" do
|
96
|
-
data.check_constraint.
|
96
|
+
expect(data.check_constraint).to be_is_a Proc
|
97
97
|
end
|
98
98
|
|
99
99
|
end # checks data in the check_constraint is Proc
|
@@ -101,7 +101,7 @@ module Partitioned
|
|
101
101
|
context "checks data in the on_field" do
|
102
102
|
|
103
103
|
it "returns on_field" do
|
104
|
-
data.on_field.call(@employee).
|
104
|
+
expect(data.on_field.call(@employee)).to eq(:integer_field)
|
105
105
|
end
|
106
106
|
|
107
107
|
end # checks data in the on_field
|
@@ -109,7 +109,7 @@ module Partitioned
|
|
109
109
|
context "checks data in the last_partitions_order_by_clause" do
|
110
110
|
|
111
111
|
it "returns last_partitions_order_by_clause" do
|
112
|
-
data.last_partitions_order_by_clause.
|
112
|
+
expect(data.last_partitions_order_by_clause).to eq("substring(tablename, 2)::integer desc")
|
113
113
|
end
|
114
114
|
|
115
115
|
end # checks data in the last_partitions_order_by_clause
|
@@ -117,7 +117,7 @@ module Partitioned
|
|
117
117
|
context "checks data in the check_constraint" do
|
118
118
|
|
119
119
|
it "returns check_constraint" do
|
120
|
-
data.check_constraint.call(@employee, 1).
|
120
|
+
expect(data.check_constraint.call(@employee, 1)).to eq("( integer_field = 1 )")
|
121
121
|
end
|
122
122
|
|
123
123
|
end # checks data in the check_constraint
|
@@ -125,11 +125,11 @@ module Partitioned
|
|
125
125
|
context "checks data in the check_constraint, when partition_table_size != 1" do
|
126
126
|
|
127
127
|
before do
|
128
|
-
@employee.
|
128
|
+
allow(@employee).to receive(:partition_table_size).and_return(2)
|
129
129
|
end
|
130
130
|
|
131
131
|
it "returns check_constraint" do
|
132
|
-
data.check_constraint.call(@employee, 1).
|
132
|
+
expect(data.check_constraint.call(@employee, 1)).to eq("( integer_field >= 0 and integer_field < 2 )")
|
133
133
|
end
|
134
134
|
|
135
135
|
end # checks data in the check_constraint, when partition_table_size != 1
|
@@ -46,7 +46,7 @@ module Partitioned
|
|
46
46
|
describe "model is abstract class" do
|
47
47
|
|
48
48
|
it "returns true" do
|
49
|
-
class_by_monthly_time_field.abstract_class.
|
49
|
+
expect(class_by_monthly_time_field.abstract_class).to be_truthy
|
50
50
|
end
|
51
51
|
|
52
52
|
end # model is abstract class
|
@@ -54,9 +54,9 @@ module Partitioned
|
|
54
54
|
describe "#partition_normalize_key_value" do
|
55
55
|
|
56
56
|
it "returns date with day set to 1st of the month" do
|
57
|
-
class_by_monthly_time_field.
|
58
|
-
partition_normalize_key_value(Date.parse('2011-01-05')).
|
59
|
-
|
57
|
+
expect(class_by_monthly_time_field.
|
58
|
+
partition_normalize_key_value(Date.parse('2011-01-05'))).
|
59
|
+
to eq(Date.parse('2011-01-01'))
|
60
60
|
end
|
61
61
|
|
62
62
|
end # #partition_normalize_key_value
|
@@ -64,7 +64,7 @@ module Partitioned
|
|
64
64
|
describe "#partition_table_size" do
|
65
65
|
|
66
66
|
it "returns 1.month" do
|
67
|
-
class_by_monthly_time_field.partition_table_size.
|
67
|
+
expect(class_by_monthly_time_field.partition_table_size).to eq(1.month)
|
68
68
|
end
|
69
69
|
|
70
70
|
end # #partition_table_size
|
@@ -78,7 +78,7 @@ module Partitioned
|
|
78
78
|
context "checks data in the base_name is Proc" do
|
79
79
|
|
80
80
|
it "returns Proc" do
|
81
|
-
data.base_name.
|
81
|
+
expect(data.base_name).to be_is_a Proc
|
82
82
|
end
|
83
83
|
|
84
84
|
end # checks data in the on_field is Proc
|
@@ -86,7 +86,7 @@ module Partitioned
|
|
86
86
|
context "checks data in the base_name" do
|
87
87
|
|
88
88
|
it "returns base_name" do
|
89
|
-
data.base_name.call(@employee, Date.parse('2011-02-05')).
|
89
|
+
expect(data.base_name.call(@employee, Date.parse('2011-02-05'))).to eq("201102")
|
90
90
|
end
|
91
91
|
|
92
92
|
end # checks data in the base_name
|
@@ -46,7 +46,7 @@ module Partitioned
|
|
46
46
|
describe "model is abstract class" do
|
47
47
|
|
48
48
|
it "returns true" do
|
49
|
-
class_by_time_field.abstract_class.
|
49
|
+
expect(class_by_time_field.abstract_class).to be_truthy
|
50
50
|
end
|
51
51
|
|
52
52
|
end # model is abstract class
|
@@ -54,9 +54,9 @@ module Partitioned
|
|
54
54
|
describe "#partition_generate_range" do
|
55
55
|
|
56
56
|
it "returns dates array" do
|
57
|
-
class_by_time_field.
|
58
|
-
partition_generate_range(Date.parse('2011-01-05'), Date.parse('2011-01-07')).
|
59
|
-
|
57
|
+
expect(class_by_time_field.
|
58
|
+
partition_generate_range(Date.parse('2011-01-05'), Date.parse('2011-01-07'))).
|
59
|
+
to eq([Date.parse('2011-01-05'), Date.parse('2011-01-06'), Date.parse('2011-01-07')])
|
60
60
|
end
|
61
61
|
|
62
62
|
end # #partition_generate_range
|
@@ -64,9 +64,9 @@ module Partitioned
|
|
64
64
|
describe "#partition_normalize_key_value" do
|
65
65
|
|
66
66
|
it "returns date" do
|
67
|
-
class_by_time_field.
|
68
|
-
partition_normalize_key_value(Date.parse('2011-01-05')).
|
69
|
-
|
67
|
+
expect(class_by_time_field.
|
68
|
+
partition_normalize_key_value(Date.parse('2011-01-05'))).
|
69
|
+
to eq(Date.parse('2011-01-05'))
|
70
70
|
end
|
71
71
|
|
72
72
|
end # #partition_normalize_key_value
|
@@ -74,7 +74,7 @@ module Partitioned
|
|
74
74
|
describe "#partition_table_size" do
|
75
75
|
|
76
76
|
it "returns 1.day" do
|
77
|
-
class_by_time_field.partition_table_size.
|
77
|
+
expect(class_by_time_field.partition_table_size).to eq(1.day)
|
78
78
|
end
|
79
79
|
|
80
80
|
end # #partition_table_size
|
@@ -82,9 +82,9 @@ module Partitioned
|
|
82
82
|
describe "#partition_time_field" do
|
83
83
|
|
84
84
|
it "raises MethodNotImplemented" do
|
85
|
-
|
85
|
+
expect {
|
86
86
|
class_by_time_field.partition_time_field
|
87
|
-
}.
|
87
|
+
}.to raise_error(MethodNotImplemented)
|
88
88
|
end
|
89
89
|
|
90
90
|
end # #partition_time_field
|
@@ -98,7 +98,7 @@ module Partitioned
|
|
98
98
|
context "checks data in the on_field is Proc" do
|
99
99
|
|
100
100
|
it "returns Proc" do
|
101
|
-
data.on_field.
|
101
|
+
expect(data.on_field).to be_is_a Proc
|
102
102
|
end
|
103
103
|
|
104
104
|
end # checks data in the on_field is Proc
|
@@ -106,7 +106,7 @@ module Partitioned
|
|
106
106
|
context "checks data in the indexes is Proc" do
|
107
107
|
|
108
108
|
it "returns Proc" do
|
109
|
-
data.indexes.first.
|
109
|
+
expect(data.indexes.first).to be_is_a Proc
|
110
110
|
end
|
111
111
|
|
112
112
|
end # checks data in the indexes is Proc
|
@@ -114,7 +114,7 @@ module Partitioned
|
|
114
114
|
context "checks data in the base_name is Proc" do
|
115
115
|
|
116
116
|
it "returns Proc" do
|
117
|
-
data.base_name.
|
117
|
+
expect(data.base_name).to be_is_a Proc
|
118
118
|
end
|
119
119
|
|
120
120
|
end # checks data in the base_name is Proc
|
@@ -122,7 +122,7 @@ module Partitioned
|
|
122
122
|
context "checks data in the check_constraint is Proc" do
|
123
123
|
|
124
124
|
it "returns Proc" do
|
125
|
-
data.check_constraint.
|
125
|
+
expect(data.check_constraint).to be_is_a Proc
|
126
126
|
end
|
127
127
|
|
128
128
|
end # checks data in the check_constraint is Proc
|
@@ -130,7 +130,7 @@ module Partitioned
|
|
130
130
|
context "checks data in the on_field" do
|
131
131
|
|
132
132
|
it "returns on_field" do
|
133
|
-
data.on_field.call(@employee).
|
133
|
+
expect(data.on_field.call(@employee)).to eq(:created_at)
|
134
134
|
end
|
135
135
|
|
136
136
|
end # checks data in the on_field
|
@@ -138,11 +138,11 @@ module Partitioned
|
|
138
138
|
context "checks data in the indexes" do
|
139
139
|
|
140
140
|
it "returns :created_at" do
|
141
|
-
data.indexes.first.call(@employee, nil).field.
|
141
|
+
expect(data.indexes.first.call(@employee, nil).field).to eq(:created_at)
|
142
142
|
end
|
143
143
|
|
144
144
|
it "returns empty options hash" do
|
145
|
-
data.indexes.first.call(@employee, nil).options.
|
145
|
+
expect(data.indexes.first.call(@employee, nil).options).to eq({})
|
146
146
|
end
|
147
147
|
|
148
148
|
end # checks data in the indexes
|
@@ -150,7 +150,7 @@ module Partitioned
|
|
150
150
|
context "checks data in the last_partitions_order_by_clause" do
|
151
151
|
|
152
152
|
it "returns last_partitions_order_by_clause" do
|
153
|
-
data.last_partitions_order_by_clause.
|
153
|
+
expect(data.last_partitions_order_by_clause).to eq("tablename desc")
|
154
154
|
end
|
155
155
|
|
156
156
|
end # checks data in the last_partitions_order_by_clause
|
@@ -158,7 +158,7 @@ module Partitioned
|
|
158
158
|
context "checks data in the base_name" do
|
159
159
|
|
160
160
|
it "returns base_name" do
|
161
|
-
data.base_name.call(@employee, Date.parse('2011-01-05')).
|
161
|
+
expect(data.base_name.call(@employee, Date.parse('2011-01-05'))).to eq("20110105")
|
162
162
|
end
|
163
163
|
|
164
164
|
end # checks data in the base_name
|
@@ -166,9 +166,9 @@ module Partitioned
|
|
166
166
|
context "checks data in the check_constraint" do
|
167
167
|
|
168
168
|
it "returns check_constraint" do
|
169
|
-
data.check_constraint.
|
170
|
-
call(@employee, Date.parse('2011-01-05')).
|
171
|
-
|
169
|
+
expect(data.check_constraint.
|
170
|
+
call(@employee, Date.parse('2011-01-05'))).
|
171
|
+
to eq("created_at >= '2011-01-05' AND created_at < '2011-01-06'")
|
172
172
|
end
|
173
173
|
|
174
174
|
end # checks data in the check_constraint
|