active_record-mti 0.3.0.pre.rc3 → 0.3.0.pre.rc4

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: 2797d1673715b1af2e8d8afc15738a50c40b79c0
4
- data.tar.gz: d28b1fdf7acd2348659f140f86221f8a6f754113
3
+ metadata.gz: c09a0c6a54ac017046879c831b9d38c9b8537814
4
+ data.tar.gz: 583b53b0da0582fc7edc5498370eb652d3504281
5
5
  SHA512:
6
- metadata.gz: 0f2678e3004f58eb2ccbb3ba77521f6bed0efe492c657b39c0d19e5ce33081326730591d89c21049d859a4ef4f29a5cd4c38f96961662b658256353f835efe55
7
- data.tar.gz: 1beed4b499349f31e093332e4e4f505aa9482bd46e47f989ae3aa0be13fc8a897596f9be2613bbf4db19e777ad76c471eafa4d72ea4e3f92d9f890f2cc523637
6
+ metadata.gz: a944519cc3c24d2119437c8161fb9f9b178cd9bb4a999baa2ae9b2956e73191b93e4bb148bbdd0adc7512b06d5b91a58bc2114ea5e0f819109c91b5c6c0a7fc8
7
+ data.tar.gz: 217552288c9020c9251634261e7634c7641f141a2bb059ff2488858ef015682828c55d5bb12e990fa84aee24ba611d81963fb1660404a087c200513428683475
data/.gitignore CHANGED
@@ -36,6 +36,7 @@
36
36
 
37
37
  # Compiled source #
38
38
  ###################
39
+ /pkg/
39
40
  *.com
40
41
  *.class
41
42
  *.dll
data/Gemfile CHANGED
@@ -10,9 +10,6 @@ group :test do
10
10
  # Publishes coverage to codeclimate
11
11
  gem 'codeclimate-test-reporter'
12
12
 
13
- # Gives CircleCI more perspective on our tests
14
- gem 'rspec_junit_formatter'
15
-
16
13
  gem 'rspec'
17
14
 
18
15
  gem 'database_cleaner'
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  [![Version ](https://img.shields.io/gem/v/active_record-mti.svg?maxAge=2592000)](https://rubygems.org/gems/active_record-mti)
2
2
  [![Build Status ](https://travis-ci.org/TwilightCoders/active_record-mti.svg)](https://travis-ci.org/TwilightCoders/active_record-mti)
3
- [![Code Climate ](https://codeclimate.com/github/TwilightCoders/active_record-mti/badges/gpa.svg)](https://codeclimate.com/github/TwilightCoders/active_record-mti)
3
+ [![Code Climate ](https://api.codeclimate.com/v1/badges/27b02e09b5da0a7ed2fc/maintainability)](https://codeclimate.com/github/TwilightCoders/active_record-mti/maintainability)
4
4
  [![Test Coverage](https://codeclimate.com/github/TwilightCoders/active_record-mti/badges/coverage.svg)](https://codeclimate.com/github/TwilightCoders/active_record-mti/coverage)
5
+ [![Dependencies ](https://gemnasium.com/badges/github.com/TwilightCoders/active_record-mti.svg)](https://gemnasium.com/github.com/TwilightCoders/active_record-mti)
5
6
 
6
7
  # ActiveRecord::MTI
7
8
 
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
 
37
37
  spec.add_development_dependency 'pry-byebug', '~> 3'
38
38
  spec.add_development_dependency 'bundler', '~> 1.3'
39
- spec.add_development_dependency 'rake', '~> 10.0'
39
+ spec.add_development_dependency 'rake', '~> 12.0'
40
40
  spec.add_development_dependency 'combustion', '~> 0.7'
41
41
 
42
42
  end
@@ -14,8 +14,8 @@ module ActiveRecord
14
14
  orignal_value = Thread.current['skip_tableoid_cast']
15
15
  Thread.current['skip_tableoid_cast'] = value
16
16
  return_value = yield if block_given?
17
+ ensure
17
18
  Thread.current['skip_tableoid_cast'] = orignal_value
18
- return return_value
19
19
  end
20
20
 
21
21
  end
@@ -6,8 +6,8 @@ module ActiveRecord
6
6
  def self.prepended(subclass)
7
7
  subclass.extend(ClassMethods)
8
8
  class << subclass
9
- class_attribute :mti_type_column
10
- class_attribute :tableoid_column
9
+ attr_reader :mti_type_column
10
+ attr_reader :tableoid_column
11
11
  end
12
12
  end
13
13
 
@@ -81,14 +81,14 @@ module ActiveRecord
81
81
  ).first
82
82
 
83
83
  tableoid = tableoid_query.try(:[], 'tableoid') || false
84
- self.tableoid_column = ActiveRecord::MTI.testify(tableoid_query.try(:[], 'has_tableoid_column'))
84
+ @tableoid_column = ActiveRecord::MTI.testify(tableoid_query.try(:[], 'has_tableoid_column'))
85
85
 
86
86
  if (has_tableoid_column?)
87
87
  ActiveRecord::MTI.logger.debug "#{table_schema}.#{table_name} has tableoid column! (#{tableoid})"
88
88
  add_tableoid_column
89
- self.mti_type_column = arel_table[:tableoid]
89
+ @mti_type_column = arel_table[:tableoid]
90
90
  else
91
- self.mti_type_column = nil
91
+ @mti_type_column = nil
92
92
  end
93
93
 
94
94
  tableoid
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module MTI
3
- VERSION = '0.3.0-rc3'
3
+ VERSION = '0.3.0-rc4'
4
4
  end
5
5
  end
@@ -2,6 +2,15 @@ require 'spec_helper'
2
2
 
3
3
  describe ActiveRecord::MTI::Calculations do
4
4
 
5
+ context 'when an exception occurs' do
6
+ it 'does not continue to adversely affect additional queries' do
7
+ Admin.create(email: 'bob')
8
+ expect{ Admin.joins(Transportation::Vehicle).count }.to raise_error(RuntimeError)
9
+ expect(Thread.current['skip_tableoid_cast']).to_not eq(true)
10
+ expect(Admin.count).to eq(1)
11
+ end
12
+ end
13
+
5
14
  context "don't project tableoid on" do
6
15
  it "grouping" do
7
16
 
@@ -44,5 +53,4 @@ describe ActiveRecord::MTI::Calculations do
44
53
  expect(sql).to match(/GROUP BY .*, \"admins\".\"tableoid\"/)
45
54
  end
46
55
  end
47
-
48
56
  end
@@ -17,6 +17,15 @@ describe ActiveRecord::MTI::Inheritance do
17
17
  context 'class definition' do
18
18
 
19
19
  describe 'for classes that use MTI' do
20
+
21
+ it 'has non-nil mti_type_column' do
22
+ expect(Admin.mti_type_column).to_not be_nil
23
+ end
24
+
25
+ it 'has true tableoid_column' do
26
+ expect(Admin.tableoid_column).to eq(true)
27
+ end
28
+
20
29
  it "doesn't check inheritance multiple times" do
21
30
  # Due to the anonymous class ("god = Class.new(Admin)") rspec can't properly distinquish
22
31
  # between the two classes. So at most 2 times!
@@ -31,6 +40,15 @@ describe ActiveRecord::MTI::Inheritance do
31
40
  end
32
41
 
33
42
  describe "for classes that don't use MTI" do
43
+
44
+ it 'has nil tableoid_column' do
45
+ expect(Post.tableoid_column).to be_nil
46
+ end
47
+
48
+ it 'has nil mti_type_column' do
49
+ expect(Post.mti_type_column).to be_nil
50
+ end
51
+
34
52
  it "doesn't check inheritance multiple times" do
35
53
  # ActiveRecord::MTI::Inheritance.register(Post, false)
36
54
  expect(Post).to receive(:check_inheritance_of).and_call_original.exactly(1).times
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActiveRecord::MTI::QueryMethods do
4
+
5
+ context "queries" do
6
+ it "select tableoid" do
7
+ sql = Admin.all.to_sql
8
+ expect(sql).to match(/SELECT .*, \"admins\".\"tableoid\" AS tableoid FROM \"admins\"/)
9
+ end
10
+ end
11
+
12
+ end
data/spec/spec_helper.rb CHANGED
@@ -5,7 +5,6 @@ require 'combustion'
5
5
 
6
6
  require 'simplecov'
7
7
  SimpleCov.start do
8
- # add_group 'Lib', 'lib'
9
8
  add_filter 'spec'
10
9
  end
11
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record-mti
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre.rc3
4
+ version: 0.3.0.pre.rc4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dale Stevens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-29 00:00:00.000000000 Z
11
+ date: 2017-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -78,14 +78,14 @@ dependencies:
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '10.0'
81
+ version: '12.0'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '10.0'
88
+ version: '12.0'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: combustion
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -134,9 +134,10 @@ files:
134
134
  - lib/active_record/mti/schema_dumper.rb
135
135
  - lib/active_record/mti/version.rb
136
136
  - lib/core_ext/hash.rb
137
- - spec/active_record/calculations_spec.rb
137
+ - spec/active_record/mti/calculations_spec.rb
138
138
  - spec/active_record/mti/inheritance_spec.rb
139
139
  - spec/active_record/mti/model_schema_spec.rb
140
+ - spec/active_record/mti/query_methods_spec.rb
140
141
  - spec/active_record/mti/schema_dumper_spec.rb
141
142
  - spec/active_record/mti_spec.rb
142
143
  - spec/active_record/sti/inheritance_spec.rb
@@ -180,9 +181,10 @@ signing_key:
180
181
  specification_version: 4
181
182
  summary: Multi Table Inheritance for PostgreSQL in Rails
182
183
  test_files:
183
- - spec/active_record/calculations_spec.rb
184
+ - spec/active_record/mti/calculations_spec.rb
184
185
  - spec/active_record/mti/inheritance_spec.rb
185
186
  - spec/active_record/mti/model_schema_spec.rb
187
+ - spec/active_record/mti/query_methods_spec.rb
186
188
  - spec/active_record/mti/schema_dumper_spec.rb
187
189
  - spec/active_record/mti_spec.rb
188
190
  - spec/active_record/sti/inheritance_spec.rb