acts_as_archival 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changes!
2
2
 
3
+ ## 0.5.1
4
+ * update to use .table_name for archived scope
5
+
3
6
  ## 0.5.0
4
7
  * Rails 4.0.0b1 support. Thanks, James Hill!
5
8
 
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009-2012 Expected Behavior
1
+ Copyright (c) 2009-2013 Expected Behavior
2
2
 
3
3
  MIT License
4
4
 
@@ -1,3 +1,3 @@
1
1
  module ActsAsArchival
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -2,7 +2,7 @@ module ExpectedBehavior
2
2
  module ActsAsArchival
3
3
  require 'digest/md5'
4
4
 
5
- ARCHIVED_CONDITIONS = lambda { |zelf| %Q{#{zelf.to_s.tableize}.archived_at IS NOT NULL AND #{zelf.to_s.tableize}.archive_number IS NOT NULL} }
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
@@ -0,0 +1,7 @@
1
+ # name - string
2
+ # archive_number - string
3
+ # archived_at - datetime
4
+ class ArchivalTableName < ActiveRecord::Base
5
+ self.table_name = "legacy"
6
+ acts_as_archival
7
+ end
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
- :independent_archival,
49
+ :archival_table_name,
50
50
  :exploder,
51
- :plain,
51
+ :independent_archival,
52
52
  :mass_attribute_protected,
53
- :readonly_when_archived,
54
53
  :missing_archived_at,
55
54
  :missing_archive_number,
56
- :poly
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.0
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-03-16 00:00:00.000000000 Z
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