Skip to content

Commit

Permalink
Fix stack error with unknown methods in array and relation futures. C…
Browse files Browse the repository at this point in the history
…loses #7
  • Loading branch information
leoasis committed May 3, 2013
1 parent 397ced0 commit 2582515
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/active_record/futures/future_calculation_array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ module ActiveRecord
module Futures
class FutureCalculationArray < FutureCalculation
include ActiveRecord::Delegation
delegate :arel, to: :relation

def initialize(relation, query, execution)
super
@klass = relation.klass
end

fetch_with(:to_a)
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/active_record/futures/future_relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module ActiveRecord
module Futures
class FutureRelation < Future
include ActiveRecord::Delegation
delegate :arel, to: :relation

def initialize(relation)
super
Expand Down
7 changes: 7 additions & 0 deletions spec/active_record/futures/future_calculation_array_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module ActiveRecord::Futures
describe FutureCalculationArray do
let(:relation) do
double(ActiveRecord::Relation, {
klass: Class.new,
arel: nil,
connection: double("connection", supports_futures?: true)
})
end
Expand All @@ -25,5 +27,10 @@ module ActiveRecord::Futures
exec_result.should have_received(:inspect)
end
end

describe "unknown method" do
let(:method_call) { ->{ subject.unknown } }
specify { method_call.should raise_error(NoMethodError) }
end
end
end
6 changes: 6 additions & 0 deletions spec/active_record/futures/future_relation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module ActiveRecord::Futures
let(:relation) do
double(ActiveRecord::Relation, {
klass: Class.new,
arel: nil,
to_a: nil,
to_sql: "select 1",
connection: double("connection", supports_futures?: true)
Expand Down Expand Up @@ -77,5 +78,10 @@ module ActiveRecord::Futures
resulting_array.should have_received(:inspect)
end
end

describe "unknown method" do
let(:method_call) { ->{ subject.unknown } }
specify { method_call.should raise_error(NoMethodError) }
end
end
end

0 comments on commit 2582515

Please sign in to comment.