dependent_restrict 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5209e19995822bf472777d6201448a094fb3d187
4
- data.tar.gz: 6cc0a772cc00306ce70584dbc8c6c967158b5d12
3
+ metadata.gz: 98d742af335bdd2b42c95160496b044c555c2fc1
4
+ data.tar.gz: 7e2b5342a2c9ce2e2d3a8f842b1221109a3317f0
5
5
  SHA512:
6
- metadata.gz: 449ec1f1875a8c6734074b6d460bbf59dc86d5f7081e3aad72c79ee948d1587ba98d41cc6224fd478d9318bce3c04d3a5b6e8e6222797b1e0f5fb59b92a8315f
7
- data.tar.gz: 38f9409944640ab6c44742ca9e72dee85b1efdcb0ec4a203446461437fcf97abd157a6643fb9eb7c1770c8defd1a4c01585e0b00261a8cf5f99ac3c490c20423
6
+ metadata.gz: b7e03ba470c1621de281bfebcc90f085502bc11c5f848e36065bf04e8b47049c516334fb08ed24fe4e61e36dba901ca97bc1ae40fb3570052a20e110b0ac3960
7
+ data.tar.gz: a06010a30a0ff6f5edff714928ac009ee42bb857a616e8ca03ddb92239a1773360db3d34c2c9e6c8860e71c85a2cfcc554f3256b4c50112ba37288903516ef05
data/Gemfile CHANGED
@@ -2,11 +2,12 @@ source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
4
  group :development, :test do
5
+ gem 'pry-debugger'
5
6
  gem 'rake', '~> 0.9.2'
6
7
  gem 'rdoc', '~> 3.12'
7
8
  gem 'rspec'
8
9
  gem 'simplecov'
9
10
  gem 'simplecov-rcov'
10
11
  gem 'sqlite3'
11
- gem 'activerecord', '~> 4.0'
12
+ gem 'activerecord', '~> 4.0.0'
12
13
  end
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'dependent_restrict'
16
- s.version = '0.2.0'
17
- s.date = '2014-05-08'
16
+ s.version = '0.2.1'
17
+ s.date = '2014-05-09'
18
18
  s.rubyforge_project = 'dependent_restrict'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -66,7 +66,8 @@ Gem::Specification.new do |s|
66
66
  dependent_restrict.gemspec
67
67
  gemfiles/rails2.gemfile
68
68
  gemfiles/rails3.gemfile
69
- gemfiles/rails4.gemfile
69
+ gemfiles/rails4_0.gemfile
70
+ gemfiles/rails4_1.gemfile
70
71
  lib/dependent_restrict.rb
71
72
  lib/dependent_restrict/delete_restriction_error.rb
72
73
  spec/dependent_restrict_spec.rb
@@ -0,0 +1,13 @@
1
+ source :rubygems
2
+ gemspec :path => '../'
3
+
4
+ group :development, :test do
5
+ gem 'rake', '~> 0.9.2'
6
+ gem 'rdoc', '~> 3.12'
7
+ gem 'rspec'
8
+ gem 'simplecov'
9
+ gem 'simplecov-rcov'
10
+ gem 'sqlite3'
11
+ gem 'activerecord', '~> 4.0.0'
12
+ end
13
+
File without changes
@@ -2,7 +2,7 @@ require 'active_record'
2
2
  require 'dependent_restrict/delete_restriction_error'
3
3
 
4
4
  module DependentRestrict
5
- VERSION = '0.2.0'
5
+ VERSION = '0.2.1'
6
6
 
7
7
  def self.included(base)
8
8
  super
@@ -45,6 +45,7 @@ module DependentRestrict
45
45
 
46
46
  def has_and_belongs_to_many_with_restrict(association_id, options = {}, &extension)
47
47
  reflection = if active_record_4?
48
+ raise ArgumentError, "dependent_restrict doesn't work with has_and_belongs_to_many. Use equivalent rails 4.1 has_many :through" if ActiveRecord::Reflection.respond_to? :create
48
49
  restrict_create_reflection(:has_and_belongs_to_many, association_id, options, scope ||= {}, self)
49
50
  else
50
51
  create_reflection(:has_and_belongs_to_many, association_id, options, self)
@@ -31,6 +31,19 @@ describe DependentRestrict do
31
31
  "Category #{id}"
32
32
  end
33
33
  end
34
+
35
+ class ProductsCategory < ActiveRecord::Base
36
+ belongs_to :product
37
+ belongs_to :category
38
+ end
39
+
40
+ class Product < ActiveRecord::Base
41
+ if ActiveRecord::Reflection.respond_to? :create
42
+ has_many :categories, :through => :products_categories
43
+ else
44
+ has_and_belongs_to_many :categories
45
+ end
46
+ end
34
47
  end
35
48
 
36
49
  after do
data/spec/schema.rb CHANGED
@@ -11,5 +11,12 @@ ActiveRecord::Schema.define(:version => 1) do
11
11
  t.integer :category_id
12
12
  t.boolean :active
13
13
  end
14
+
15
+ create_table :product do |t|
16
+ end
17
+
18
+ create_table :products_categories do |t|
19
+ t.integer :product_id, :category_id
20
+ end
14
21
  end
15
22
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependent_restrict
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Noack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-08 00:00:00.000000000 Z
11
+ date: 2014-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -46,7 +46,8 @@ files:
46
46
  - dependent_restrict.gemspec
47
47
  - gemfiles/rails2.gemfile
48
48
  - gemfiles/rails3.gemfile
49
- - gemfiles/rails4.gemfile
49
+ - gemfiles/rails4_0.gemfile
50
+ - gemfiles/rails4_1.gemfile
50
51
  - lib/dependent_restrict.rb
51
52
  - lib/dependent_restrict/delete_restriction_error.rb
52
53
  - spec/dependent_restrict_spec.rb