acts_as_archive 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -101,4 +101,19 @@ end
101
101
  </pre>
102
102
 
103
103
  Call <code>ActsAsArchive.update</code> upon adding new indexes
104
- (see <a href="#create_archive_tables">_Create archive tables_</a>).
104
+ (see <a href="#create_archive_tables">_Create archive tables_</a>).
105
+
106
+ Delete records without archiving
107
+ --------------------------------
108
+
109
+ To destroy a record without archiving:
110
+
111
+ <pre>
112
+ article.destroy!
113
+ </pre>
114
+
115
+ To delete multiple records without archiving:
116
+
117
+ <pre>
118
+ Article.delete_all!(["id in (?)", [1,2,3]])
119
+ </pre>
@@ -28,6 +28,10 @@ module ActsAsArchive
28
28
  insert_cols << 'deleted_at'
29
29
  select_cols << "'#{Time.now.utc.to_s(:db)}'"
30
30
  end
31
+
32
+ insert_cols.map! { |col| connection.quote_column_name(col) }
33
+ select_cols.map! { |col| col =~ /^\'/ ? col : connection.quote_column_name(col) }
34
+
31
35
  connection.execute(%{
32
36
  INSERT INTO archived_#{table_name} (#{insert_cols.join(', ')})
33
37
  SELECT #{select_cols.join(', ')}
@@ -14,6 +14,7 @@ module ActsAsArchive
14
14
  def copy_from_archive(conditions)
15
15
  add_conditions!(where = '', conditions)
16
16
  col_names = column_names - [ 'deleted_at' ]
17
+ col_names.map! { |col| connection.quote_column_name(col) }
17
18
  connection.execute(%{
18
19
  INSERT INTO #{table_name} (#{col_names.join(', ')})
19
20
  SELECT #{col_names.join(', ')}
data/require.rb CHANGED
@@ -17,7 +17,7 @@ Require do
17
17
  name 'acts_as_archive'
18
18
  homepage "http://github.com/winton/#{name}"
19
19
  summary "Don't delete your records, move them to a different table"
20
- version '0.2.2'
20
+ version '0.2.3'
21
21
  end
22
22
 
23
23
  lib do
@@ -20,6 +20,20 @@ describe ActsAsArchive::Base::Destroy do
20
20
  end
21
21
 
22
22
  end
23
+
24
+ describe 'destroy!' do
25
+
26
+ before(:all) do
27
+ create_records
28
+ @article = Article.first
29
+ end
30
+
31
+ it "should really destroy a records" do
32
+ @article.destroy!
33
+ Article::Archive.count.should == 0
34
+ end
35
+
36
+ end
23
37
 
24
38
  describe 'delete_all' do
25
39
 
@@ -100,4 +114,4 @@ describe ActsAsArchive::Base::Destroy do
100
114
  end
101
115
  end
102
116
  end
103
- end
117
+ end
data/spec/spec_helper.rb CHANGED
@@ -43,7 +43,7 @@ def create_records(klass=Article, values={})
43
43
  end
44
44
  end
45
45
  connection.execute(%{
46
- INSERT INTO #{table} (#{cols.collect { |c| "#{c}" }.join(', ')})
46
+ INSERT INTO #{table} (#{cols.collect { |c| "#{connection.quote_column_name(c)}" }.join(', ')})
47
47
  VALUES (#{vals.join(', ')})
48
48
  })
49
49
  klass.find(x)
@@ -69,6 +69,7 @@ def establish_test_db
69
69
  connection.create_table(:articles) do |t|
70
70
  t.string :title
71
71
  t.string :body
72
+ t.boolean :read # break mysql w/o quotation
72
73
  end
73
74
  # Load the model
74
75
  load "#{SPEC}/db/models/article.rb"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_archive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
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-02-21 00:00:00 -08:00
12
+ date: 2010-03-03 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,7 +42,6 @@ files:
42
42
  - lib/acts_as_archive/migration.rb
43
43
  - lib/acts_as_archive.rb
44
44
  - MIT-LICENSE
45
- - pkg/acts_as_archive-0.2.1.gem
46
45
  - rails/init.rb
47
46
  - Rakefile
48
47
  - README.markdown
Binary file