unscoped_associations 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2cd5582dcc1e8d3a4fe22a00bd5d1a93a6466df5
4
+ data.tar.gz: 21129a908c3f75f70462e000b7e145d8a8dd57be
5
+ SHA512:
6
+ metadata.gz: 7e39f18b8aefb84c2e4fd288f6706367397bf08e8a89cfb8945a82b4339cde54f72306a2441391077b09a10cbbb9df4b6bf51319549b6efe714211245953ac14
7
+ data.tar.gz: 19574587b4d3d79b10513e26d022938e7ba57717be501712d5bb662e42c28bcfa0aa4b87acfcc68b879335858c46abf95b5345db22180fdb48ee7267f2a20bfa
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
3
+ - 2.1
4
+ - 2.0
4
5
  - 1.9.3
data/Gemfile CHANGED
@@ -1,9 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gemspec
4
-
5
- group :development, :test do
6
- gem 'rake'
7
- gem 'rspec'
8
- gem 'sqlite3'
9
- end
3
+ gemspec
data/README.md CHANGED
@@ -9,19 +9,21 @@ Want to skip the `default_scope` when you get objects through associations (for
9
9
  * `:has_many`
10
10
 
11
11
  ## Installation
12
+
12
13
  Add this line to your Gemfile:
13
14
 
14
15
  ```ruby
15
16
  gem 'unscoped_associations'
16
17
  ```
17
18
 
18
- Or install the gem:
19
+ Or install the gem manually:
19
20
 
20
21
  ```ruby
21
22
  gem install unscoped_associations
22
23
  ```
23
24
 
24
25
  ## Usage
26
+
25
27
  Basic usage example:
26
28
 
27
29
  ```ruby
@@ -47,11 +49,12 @@ end
47
49
  ```
48
50
 
49
51
  ## Status
50
- Tested on Rails 3.x series and Rails 4.0.0. Originally thought and built for Rails 3, Rails 4 supported.
51
52
 
52
- NOTE: Rails 4 introduces some updates (and more planned for upcoming releases) related to this part. For example, in Rails 4, you are able to customize associations using a scope block, so you can skip `default_scope`:
53
+ Tested on Rails 3 series and Rails 4. Originally was thought and built for Rails 3, but Rails 4 is also supported.
53
54
 
54
- ```ruby
55
+ **NOTE** Rails 4 introduces some updates (and more planned for upcoming releases) related to this part. For example, in Rails 4, you are able to customize associations using a scope block, so you can skip the `default_scope` by:
56
+
57
+ ```
55
58
  class User < ActiveRecord::Base
56
59
  has_many :all_comments, -> { where(public: [true, false]) }, class_name: 'Comment'
57
60
  end
@@ -60,7 +63,9 @@ end
60
63
  Anyway, you can use `unscoped` option, if you prefer.
61
64
 
62
65
  ## Contributing
66
+
63
67
  Ideas, fixes, improvements or any comment are welcome!
64
68
 
65
69
  ## License
70
+
66
71
  Copyright (c) 2013-2014 Marc Anguera. Unscoped Associations is released under the [MIT](LICENSE) License.
@@ -1,3 +1,3 @@
1
1
  module UnscopedAssociations
2
- VERSION = "0.6.4"
2
+ VERSION = "0.6.5"
3
3
  end
@@ -1,7 +1,6 @@
1
1
  require 'unscoped_associations/version'
2
2
 
3
3
  module UnscopedAssociations
4
-
5
4
  def self.included(base)
6
5
  base.extend ClassMethods
7
6
  (class << base; self; end).instance_eval do
@@ -12,7 +11,6 @@ module UnscopedAssociations
12
11
  end
13
12
 
14
13
  module ClassMethods
15
-
16
14
  def belongs_to_with_unscoped(name, scope = nil, options = {})
17
15
  build_unscoped(:belongs_to, name, scope, options)
18
16
  end
data/spec/spec_helper.rb CHANGED
@@ -9,7 +9,6 @@ ActiveRecord::Base.logger = Logger.new(STDOUT)
9
9
  Dir["./spec/support/**/*.rb"].sort.each {|f| require f}
10
10
 
11
11
  RSpec.configure do |config|
12
- config.treat_symbols_as_metadata_keys_with_true_values = true
13
12
  config.run_all_when_everything_filtered = true
14
13
  config.mock_with :rspec
15
14
  config.order = 'random'
@@ -1,72 +1,58 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe UnscopedAssociations do
4
- let(:user) { User.create active: false }
5
- let(:comment) { Comment.create user_id: user.id, public: false }
6
- let(:user_vote) { user.votes.create public: false }
7
- let(:comment_vote) { comment.votes.create }
4
+ let!(:user) { User.create(active: false) }
5
+ let!(:comment) { Comment.create(user_id: user.id, public: false) }
6
+ let!(:user_vote) { user.votes.create(public: false) }
7
+ let!(:comment_vote) { comment.votes.create }
8
8
 
9
9
  context 'a belongs to association' do
10
- subject { comment }
10
+ it 'scoped' do
11
+ expect(comment.user).to be_nil
12
+ expect(comment.scoped_user).to be_nil
13
+ end
11
14
 
12
- context 'scoped' do
13
- its(:user) { should be_nil }
14
- its(:scoped_user) { should be_nil }
15
+ it 'unscoped' do
16
+ expect(comment.unscoped_user).to eq(user)
15
17
  end
16
18
 
17
- context 'unscoped' do
18
- its(:unscoped_user) { should eq user }
19
+ it 'unscoped polymorphic' do
20
+ expect(comment_vote.votable).to eq(comment)
19
21
  end
20
22
  end
21
23
 
22
24
  context 'a has one association' do
23
- subject { user }
24
-
25
- context 'scoped' do
26
- its(:last_comment) { should be_nil }
25
+ it 'scoped' do
26
+ expect(user.last_comment).to be_nil
27
27
  end
28
28
 
29
- context 'unscoped' do
30
- its(:unscoped_last_comment) { should eq comment }
29
+ it 'unscoped' do
30
+ expect(user.unscoped_last_comment).to eq(comment)
31
31
  end
32
32
  end
33
33
 
34
34
  context 'a has many association' do
35
- subject { user }
36
-
37
- context 'scoped' do
38
- its(:comments) { should be_empty }
39
-
40
- context 'with an extension' do
41
- its('comments.today') { should be_empty }
42
- end
35
+ it 'scoped' do
36
+ expect(user.comments).to be_empty
43
37
  end
44
38
 
45
- context 'unscoped' do
46
- its(:unscoped_comments) { should eq [comment] }
47
-
48
- context 'with an extension' do
49
- # Extended methods take the default_scope
50
- its('unscoped_comments.today') { should be_empty }
51
- # Ideally, it should skip the default_scope
52
- # its('unscoped_comments.today') { should eq [comment] }
53
- end
39
+ it 'scoped with an extension' do
40
+ expect(user.comments.today).to be_empty
54
41
  end
55
- end
56
-
57
- context 'has_many with unscoped polymorphic' do
58
- subject { user }
59
42
 
60
- context 'unscoped_votable' do
61
- its(:votes) { should eq [user_vote] }
43
+ it 'unscoped' do
44
+ expect(user.unscoped_comments).to eq([comment])
62
45
  end
63
- end
64
46
 
65
- context 'belongs_to with unscoped polymorphic' do
66
- subject { comment_vote }
47
+ it 'unscoped with an extension' do
48
+ # Extended methods take the default_scope
49
+ expect(user.unscoped_comments.today).to be_empty
50
+ # Ideally, it should skip the default_scope
51
+ # expect(user.unscoped_comments.today).to eq([comment])
52
+ end
67
53
 
68
- context 'unscoped_votable' do
69
- its(:votable) { should eq comment }
54
+ it 'unscoped polymorphic' do
55
+ expect(user.votes).to eq([user_vote])
70
56
  end
71
57
  end
72
58
  end
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.add_dependency "activerecord", ">= 0"
20
20
 
21
- spec.add_development_dependency "debugger"
22
- spec.add_development_dependency "rspec"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rspec", '~> 3.1'
23
23
  spec.add_development_dependency "sqlite3"
24
24
  end
25
25
 
metadata CHANGED
@@ -1,78 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unscoped_associations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
5
- prerelease:
4
+ version: 0.6.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Marc Anguera Insa
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-04-22 00:00:00.000000000 Z
11
+ date: 2014-09-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activerecord
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
- name: debugger
28
+ name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '0'
47
+ version: '3.1'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
- version: '0'
54
+ version: '3.1'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: sqlite3
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  description: Skip default_scope in your associations
@@ -82,8 +73,8 @@ executables: []
82
73
  extensions: []
83
74
  extra_rdoc_files: []
84
75
  files:
85
- - .gitignore
86
- - .travis.yml
76
+ - ".gitignore"
77
+ - ".travis.yml"
87
78
  - Gemfile
88
79
  - LICENSE
89
80
  - README.md
@@ -98,27 +89,26 @@ files:
98
89
  homepage: https://github.com/markets/unscoped_associations
99
90
  licenses:
100
91
  - MIT
92
+ metadata: {}
101
93
  post_install_message:
102
94
  rdoc_options: []
103
95
  require_paths:
104
96
  - lib
105
97
  required_ruby_version: !ruby/object:Gem::Requirement
106
- none: false
107
98
  requirements:
108
- - - ! '>='
99
+ - - ">="
109
100
  - !ruby/object:Gem::Version
110
101
  version: '0'
111
102
  required_rubygems_version: !ruby/object:Gem::Requirement
112
- none: false
113
103
  requirements:
114
- - - ! '>='
104
+ - - ">="
115
105
  - !ruby/object:Gem::Version
116
106
  version: '0'
117
107
  requirements: []
118
108
  rubyforge_project:
119
- rubygems_version: 1.8.23
109
+ rubygems_version: 2.2.0
120
110
  signing_key:
121
- specification_version: 3
111
+ specification_version: 4
122
112
  summary: Skip default_scope in your associations
123
113
  test_files:
124
114
  - spec/spec_helper.rb