acts_as_archival 0.5.0 → 0.5.1
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.md +3 -0
- data/LICENSE +1 -1
- data/lib/acts_as_archival/version.rb +1 -1
- data/lib/expected_behavior/acts_as_archival.rb +1 -1
- data/test/fixtures/archival_table_name.rb +7 -0
- data/test/schema.rb +6 -0
- data/test/scope_test.rb +5 -0
- data/test/test_helper.rb +5 -4
- metadata +4 -2
data/CHANGELOG.md
CHANGED
data/LICENSE
CHANGED
@@ -2,7 +2,7 @@ module ExpectedBehavior
|
|
2
2
|
module ActsAsArchival
|
3
3
|
require 'digest/md5'
|
4
4
|
|
5
|
-
ARCHIVED_CONDITIONS = lambda { |zelf| %Q{#{zelf.
|
5
|
+
ARCHIVED_CONDITIONS = lambda { |zelf| %Q{#{zelf.table_name}.archived_at IS NOT NULL AND #{zelf.table_name}.archive_number IS NOT NULL} }
|
6
6
|
UNARCHIVED_CONDITIONS = { :archived_at => nil, :archive_number => nil }
|
7
7
|
|
8
8
|
MissingArchivalColumnError = Class.new(ActiveRecord::ActiveRecordError) unless defined?(MissingArchivalColumnError) == 'constant' && MissingArchivalColumnError.class == Class
|
data/test/schema.rb
CHANGED
@@ -64,4 +64,10 @@ ActiveRecord::Schema.define(:version => 1) do
|
|
64
64
|
t.column :archive_number, :string
|
65
65
|
t.column :archived_at, :datetime
|
66
66
|
end
|
67
|
+
|
68
|
+
create_table :legacy, :force => true do |t|
|
69
|
+
t.column :name, :string
|
70
|
+
t.column :archive_number, :string
|
71
|
+
t.column :archived_at, :datetime
|
72
|
+
end
|
67
73
|
end
|
data/test/scope_test.rb
CHANGED
@@ -47,4 +47,9 @@ class ActsAsArchivalTest < ActiveSupport::TestCase
|
|
47
47
|
|
48
48
|
assert_equal 1, Archival.archived_from_archive_number(archive_number).count
|
49
49
|
end
|
50
|
+
|
51
|
+
test "table_name is set to 'legacy'" do
|
52
|
+
assert_equal "SELECT `legacy`.* FROM `legacy` WHERE (legacy.archived_at IS NOT NULL AND legacy.archive_number IS NOT NULL)", ArchivalTableName.archived.to_sql
|
53
|
+
assert_equal "SELECT `legacy`.* FROM `legacy` WHERE `legacy`.`archived_at` IS NULL AND `legacy`.`archive_number` IS NULL", ArchivalTableName.unarchived.to_sql
|
54
|
+
end
|
50
55
|
end
|
data/test/test_helper.rb
CHANGED
@@ -46,14 +46,15 @@ def require_test_classes
|
|
46
46
|
[:archival,
|
47
47
|
:archival_kid,
|
48
48
|
:archival_grandkid,
|
49
|
-
:
|
49
|
+
:archival_table_name,
|
50
50
|
:exploder,
|
51
|
-
:
|
51
|
+
:independent_archival,
|
52
52
|
:mass_attribute_protected,
|
53
|
-
:readonly_when_archived,
|
54
53
|
:missing_archived_at,
|
55
54
|
:missing_archive_number,
|
56
|
-
:
|
55
|
+
:plain,
|
56
|
+
:poly,
|
57
|
+
:readonly_when_archived
|
57
58
|
].each {|test_class_file| require_relative "fixtures/#{test_class_file}"}
|
58
59
|
end
|
59
60
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_archival
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -16,7 +16,7 @@ authors:
|
|
16
16
|
autorequire:
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
|
-
date: 2013-
|
19
|
+
date: 2013-05-17 00:00:00.000000000 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: activerecord
|
@@ -185,6 +185,7 @@ files:
|
|
185
185
|
- test/fixtures/archival.rb
|
186
186
|
- test/fixtures/archival_grandkid.rb
|
187
187
|
- test/fixtures/archival_kid.rb
|
188
|
+
- test/fixtures/archival_table_name.rb
|
188
189
|
- test/fixtures/exploder.rb
|
189
190
|
- test/fixtures/independent_archival.rb
|
190
191
|
- test/fixtures/mass_attribute_protected.rb
|
@@ -237,6 +238,7 @@ test_files:
|
|
237
238
|
- test/fixtures/archival.rb
|
238
239
|
- test/fixtures/archival_grandkid.rb
|
239
240
|
- test/fixtures/archival_kid.rb
|
241
|
+
- test/fixtures/archival_table_name.rb
|
240
242
|
- test/fixtures/exploder.rb
|
241
243
|
- test/fixtures/independent_archival.rb
|
242
244
|
- test/fixtures/mass_attribute_protected.rb
|