Skip to content

Commit bc949c7

Browse files
committed
wip fixed 2 regressions
1 parent 276a30f commit bc949c7

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

ruby/hyper-model/Rakefile

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
11
require "bundler/gem_tasks"
22
require "rspec/core/rake_task"
33

4+
def run_batches(batches)
5+
failed = false
6+
batches.each do |batch|
7+
begin
8+
Rake::Task["spec:batch#{batch}"].invoke
9+
rescue SystemExit
10+
failed = true
11+
end
12+
end
13+
exit 1 if failed
14+
end
15+
16+
417
task :part1 do
5-
(1..2).each { |batch| Rake::Task["spec:batch#{batch}"].invoke rescue nil }
18+
run_batches(1..2)
619
end
720

821
task :part2 do
9-
(3..4).each { |batch| Rake::Task["spec:batch#{batch}"].invoke rescue nil }
22+
run_batches(3..4)
1023
end
1124

1225
task :part3 do
13-
(5..7).each { |batch| Rake::Task["spec:batch#{batch}"].invoke rescue nil }
26+
run_batches(5..7)
1427
end
1528

1629
task :spec do
17-
(1..7).each { |batch| Rake::Task["spec:batch#{batch}"].invoke rescue nil }
30+
run_batches(1..7)
1831
end
1932

2033
namespace :spec do
@@ -23,7 +36,6 @@ namespace :spec do
2336
end
2437
(1..7).each do |batch|
2538
RSpec::Core::RakeTask.new(:"batch#{batch}") do |t|
26-
t.fail_on_error = false unless batch == 7
2739
t.pattern = "spec/batch#{batch}/**/*_spec.rb"
2840
end
2941
end

ruby/hyper-model/lib/reactive_record/active_record/associations.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def source_belongs_to_association # private
126126
# given self is a has_many_through association return the corresponding belongs_to association
127127
# for the source
128128
@source_belongs_to_association ||=
129-
through_association.inverse.owner_class.detect do |sibling|
129+
through_association.inverse.owner_class.reflect_on_all_associations.detect do |sibling|
130130
sibling.attribute == source
131131
end
132132
end
@@ -141,8 +141,6 @@ def polymorphic?
141141
end
142142

143143
def inverse(model = nil)
144-
raise "internal assertion failure: #{self}.inverse called without a model, "\
145-
"and #{self} is not a collection" unless model || collection?
146144
return @inverse if @inverse
147145
ta = through_association
148146
found = ta ? ta.inverse : find_inverse(model)

ruby/hyper-model/spec/batch7/poly_assoc_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def self.build_tables
142142
end
143143

144144
has_many :memberships
145-
has_many :groups, through: :memberships, source: :memerable, source_type: 'Group'
145+
has_many :groups, through: :memberships, source: :memerable, source_type: 'Group'
146146
has_many :projects, through: :memberships, source: :memerable, source_type: 'Project'
147147
end
148148

0 commit comments

Comments
 (0)