unscoped_associations 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
data/Gemfile CHANGED
@@ -1,3 +1,9 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- gemspec
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ gem 'rake'
7
+ gem 'rspec'
8
+ gem 'sqlite3'
9
+ end
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Unscoped Associations
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/unscoped_associations.png)](http://badge.fury.io/rb/unscoped_associations)
4
+ [![Build Status](https://travis-ci.org/markets/unscoped_associations.svg?branch=master)](https://travis-ci.org/markets/unscoped_associations)
4
5
 
5
6
  Want to skip the `default_scope` when you get objects through associations (for some strange reasons)? Do it easily with this lib. Supported associations:
6
7
  * `:belongs_to`
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
- require "bundler/gem_tasks"
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -1,3 +1,3 @@
1
1
  module UnscopedAssociations
2
- VERSION = "0.4.2"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -0,0 +1,47 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+
4
+ require 'active_record'
5
+ require 'unscoped_associations'
6
+
7
+ ActiveRecord::Base.logger = Logger.new(STDOUT)
8
+
9
+ ActiveRecord::Base.establish_connection(
10
+ :adapter => 'sqlite3',
11
+ :database => ':memory:'
12
+ )
13
+
14
+ ActiveRecord::Schema.define do
15
+ self.verbose = false
16
+
17
+ create_table :users, :force => true do |t|
18
+ t.boolean :active
19
+ end
20
+
21
+ create_table :comments, :force => true do |t|
22
+ t.integer :user_id
23
+ t.boolean :public
24
+ end
25
+ end
26
+
27
+ class User < ActiveRecord::Base
28
+ has_many :comments
29
+ has_many :all_comments, class_name: 'Comment', unscoped: true
30
+ has_one :last_comment, class_name: 'Comment', order: 'id DESC', unscoped: true
31
+
32
+ default_scope where( active: true )
33
+ end
34
+
35
+ class Comment < ActiveRecord::Base
36
+ belongs_to :user, unscoped: true
37
+
38
+ default_scope where( public: true )
39
+ end
40
+
41
+ RSpec.configure do |config|
42
+ config.treat_symbols_as_metadata_keys_with_true_values = true
43
+ config.run_all_when_everything_filtered = true
44
+ config.filter_run :focus
45
+ config.mock_with :rspec
46
+ config.order = 'random'
47
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe UnscopedAssociations do
4
+ it 'belongs_to with unscoped option should skip default_scope' do
5
+ user = User.create(:active => false)
6
+ comment = Comment.create(:user_id => user.id)
7
+
8
+ expect(comment.user).to eq(user)
9
+ end
10
+ end
@@ -19,5 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.add_dependency "activerecord", ">= 0"
20
20
 
21
21
  spec.add_development_dependency "debugger"
22
+ spec.add_development_dependency "rspec"
23
+ spec.add_development_dependency "sqlite3"
22
24
  end
23
25
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unscoped_associations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-08 00:00:00.000000000 Z
12
+ date: 2014-03-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -43,6 +43,38 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: sqlite3
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
46
78
  description: Skip default_scope in your associations
47
79
  email:
48
80
  - srmarc.ai@gmail.com
@@ -51,12 +83,15 @@ extensions: []
51
83
  extra_rdoc_files: []
52
84
  files:
53
85
  - .gitignore
86
+ - .travis.yml
54
87
  - Gemfile
55
88
  - LICENSE
56
89
  - README.md
57
90
  - Rakefile
58
91
  - lib/unscoped_associations.rb
59
92
  - lib/unscoped_associations/version.rb
93
+ - spec/spec_helper.rb
94
+ - spec/unscoped_associations_spec.rb
60
95
  - unscoped_associations.gemspec
61
96
  homepage: https://github.com/markets/unscoped_associations
62
97
  licenses:
@@ -83,4 +118,6 @@ rubygems_version: 1.8.23
83
118
  signing_key:
84
119
  specification_version: 3
85
120
  summary: Skip default_scope in your associations
86
- test_files: []
121
+ test_files:
122
+ - spec/spec_helper.rb
123
+ - spec/unscoped_associations_spec.rb