soft_deletion 0.4.0 → 0.4.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/.travis.yml CHANGED
@@ -1,5 +1,13 @@
1
- script: "bundle exec rake"
2
1
  rvm:
3
- - ree
4
- - 1.9.2
5
2
  - 1.9.3
3
+ - 1.8.7
4
+ - 2.0
5
+ gemfile:
6
+ - gemfiles/rails2.gemfile
7
+ - gemfiles/rails3.gemfile
8
+ - gemfiles/rails4.gemfile
9
+ matrix:
10
+ exclude:
11
+ - rvm: 2.0
12
+ gemfile: gemfiles/rails2.gemfile
13
+ script: "rake spec"
data/Appraisals CHANGED
@@ -9,3 +9,10 @@ appraise "rails3" do
9
9
  gem 'activerecord', version
10
10
  gem 'activesupport', version
11
11
  end
12
+
13
+ appraise "rails4" do
14
+ version = "4.0.0.beta1"
15
+ gem 'activerecord', version
16
+ gem 'activesupport', version
17
+ end
18
+
data/Gemfile CHANGED
@@ -7,5 +7,5 @@ gem 'appraisal'
7
7
  gem 'rake'
8
8
  gem 'sqlite3'
9
9
  gem 'rspec'
10
- gem 'database_cleaner'
10
+ gem 'database_cleaner', '1.0.0.RC1' # or rails 4 tests fail
11
11
  gem 'bump'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- soft_deletion (0.4.0)
4
+ soft_deletion (0.4.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -23,7 +23,7 @@ GEM
23
23
  arel (3.0.2)
24
24
  builder (3.0.0)
25
25
  bump (0.3.8)
26
- database_cleaner (0.8.0)
26
+ database_cleaner (1.0.0.RC1)
27
27
  diff-lcs (1.1.3)
28
28
  i18n (0.6.0)
29
29
  multi_json (1.3.6)
@@ -47,7 +47,7 @@ DEPENDENCIES
47
47
  activesupport
48
48
  appraisal
49
49
  bump
50
- database_cleaner
50
+ database_cleaner (= 1.0.0.RC1)
51
51
  rake
52
52
  rspec
53
53
  soft_deletion!
@@ -1,12 +1,12 @@
1
1
  # This file was generated by Appraisal
2
2
 
3
- source :rubygems
3
+ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
6
  gem "rake"
7
7
  gem "sqlite3"
8
8
  gem "rspec"
9
- gem "database_cleaner"
9
+ gem "database_cleaner", "1.0.0.RC1"
10
10
  gem "bump"
11
11
  gem "activerecord", "2.3.14"
12
12
  gem "activesupport", "2.3.14"
@@ -1,12 +1,12 @@
1
1
  # This file was generated by Appraisal
2
2
 
3
- source :rubygems
3
+ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
6
  gem "rake"
7
7
  gem "sqlite3"
8
8
  gem "rspec"
9
- gem "database_cleaner"
9
+ gem "database_cleaner", "1.0.0.RC1"
10
10
  gem "bump"
11
11
  gem "activerecord", "3.2.3"
12
12
  gem "activesupport", "3.2.3"
@@ -0,0 +1,14 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rake"
7
+ gem "sqlite3"
8
+ gem "rspec"
9
+ gem "database_cleaner", "1.0.0.RC1"
10
+ gem "bump"
11
+ gem "activerecord", "4.0.0.beta1"
12
+ gem "activesupport", "4.0.0.beta1"
13
+
14
+ gemspec :path=>"../"
@@ -23,7 +23,8 @@ module SoftDeletion
23
23
  end
24
24
 
25
25
  def with_deleted
26
- with_exclusive_scope do
26
+ method = (ActiveRecord::VERSION::MAJOR >= 4 ? :unscoped : :with_exclusive_scope)
27
+ send(method) do
27
28
  yield self
28
29
  end
29
30
  end
@@ -40,11 +41,20 @@ module SoftDeletion
40
41
  models = ids_or_models
41
42
  else
42
43
  ids = ids_or_models
43
- models = all(:conditions => { :id => ids })
44
+ models = if ActiveRecord::VERSION::MAJOR >= 4
45
+ where(:id => ids)
46
+ else
47
+ all(:conditions => { :id => ids })
48
+ end
44
49
  end
45
50
 
46
51
  transaction do
47
- update_all(mark_as_soft_deleted_sql, :id => ids)
52
+ if ActiveRecord::VERSION::MAJOR >= 4
53
+ where(:id => ids).update_all(mark_as_soft_deleted_sql)
54
+ else
55
+ update_all(mark_as_soft_deleted_sql, :id => ids)
56
+ end
57
+
48
58
  models.each do |model|
49
59
  model.soft_delete_dependencies.each(&:soft_delete!)
50
60
  model.run_callbacks ActiveRecord::VERSION::MAJOR > 2 ? :soft_delete : :after_soft_delete
@@ -1,3 +1,3 @@
1
1
  module SoftDeletion
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
@@ -9,6 +9,9 @@ Gem::Specification.new name, SoftDeletion::VERSION do |s|
9
9
  s.homepage = "https://github.com/grosser/#{name}"
10
10
  s.files = `git ls-files`.split("\n")
11
11
  s.license = "MIT"
12
- s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem")
13
- s.cert_chain = ["gem-public_cert.pem"]
12
+ key = File.expand_path("~/.ssh/gem-private_key.pem")
13
+ if File.exist?(key)
14
+ s.signing_key = key
15
+ s.cert_chain = ["gem-public_cert.pem"]
16
+ end
14
17
  end
data/spec/spec_helper.rb CHANGED
@@ -39,6 +39,7 @@ ActiveRecord::Base.establish_connection(
39
39
  )
40
40
 
41
41
  # create tables
42
+ ActiveRecord::Schema.verbose = false
42
43
  ActiveRecord::Schema.define(:version => 1) do
43
44
  create_table :forums do |t|
44
45
  t.integer :category_id
@@ -149,8 +150,11 @@ class Cat1Forum < ActiveRecord::Base
149
150
  silent_set_table_name 'forums'
150
151
 
151
152
  has_soft_deletion
152
- default_scope :conditions => {:category_id => 1}
153
-
153
+ if ActiveRecord::VERSION::MAJOR >= 4
154
+ default_scope { where(:category_id => 1) }
155
+ else
156
+ default_scope :conditions => {:category_id => 1}
157
+ end
154
158
 
155
159
  belongs_to :category
156
160
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soft_deletion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -36,7 +36,7 @@ cert_chain:
36
36
  VHNmKzZNYWVud0FNa0FnSGRzd0dzSnp0T25ObkJhM0YKeTBrQ1NXbUs2RCt4
37
37
  L1NiZlM2cjdLZTA3TVJxemlKZEI5R3VFMSswY0lSdUZoOEVRK0xONkhYQ0tN
38
38
  NXBvbi9HVQp5Y3dNWGZsMAotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
39
- date: 2013-03-03 00:00:00.000000000 Z
39
+ date: 2013-04-24 00:00:00.000000000 Z
40
40
  dependencies: []
41
41
  description:
42
42
  email: michael@grosser.it
@@ -55,6 +55,7 @@ files:
55
55
  - gem-public_cert.pem
56
56
  - gemfiles/rails2.gemfile
57
57
  - gemfiles/rails3.gemfile
58
+ - gemfiles/rails4.gemfile
58
59
  - lib/soft_deletion.rb
59
60
  - lib/soft_deletion/core.rb
60
61
  - lib/soft_deletion/dependency.rb
@@ -78,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
79
  version: '0'
79
80
  segments:
80
81
  - 0
81
- hash: 2665204581756557410
82
+ hash: 4177162783989057611
82
83
  required_rubygems_version: !ruby/object:Gem::Requirement
83
84
  none: false
84
85
  requirements:
@@ -87,10 +88,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
88
  version: '0'
88
89
  segments:
89
90
  - 0
90
- hash: 2665204581756557410
91
+ hash: 4177162783989057611
91
92
  requirements: []
92
93
  rubyforge_project:
93
- rubygems_version: 1.8.24
94
+ rubygems_version: 1.8.25
94
95
  signing_key:
95
96
  specification_version: 3
96
97
  summary: Explicit soft deletion for ActiveRecord via deleted_at and default scope.
metadata.gz.sig CHANGED
Binary file