Skip to content

Commit

Permalink
Merge pull request sunspot#628 from 4r2r/fix-data-accessor-for-stub-i…
Browse files Browse the repository at this point in the history
…ssue

Fix: undefined method data_accessor_for for StubSessionProxy::Search
  • Loading branch information
njakobsen committed Mar 22, 2015
2 parents 16e5f62 + 376ceb4 commit 1c3dbd6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
26 changes: 17 additions & 9 deletions sunspot_rails/lib/sunspot/rails/stub_session_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ def new_more_like_this(*args)
Search.new
end

class DataAccessorStub
attr_accessor :include, :select
end

class Search

def build
self
end
Expand Down Expand Up @@ -102,28 +106,32 @@ def dynamic_facet(name)
FacetStub.new
end

def data_accessor_for(klass)
DataAccessorStub.new
end

def execute
self
end
end


class PaginatedCollection < Array

def total_count
0
end
alias :total_entries :total_count

def current_page
1
end

def per_page
30
end
alias :limit_value :per_page

def total_pages
1
end
Expand Down Expand Up @@ -152,7 +160,7 @@ def out_of_bounds?
def offset
0
end

end

class FacetStub
Expand All @@ -162,7 +170,7 @@ def rows
end

end

end
end
end
14 changes: 14 additions & 0 deletions sunspot_rails/spec/stub_session_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,19 @@
it 'should return empty array if listing facets' do
@search.facets.should == []
end

describe '#data_accessor_for' do
before do
@accessor = @search.data_accessor_for(Post)
end

it 'should provide accessor for select' do
@accessor.should respond_to(:select, :select=)
end

it 'should provide accessor for include' do
@accessor.should respond_to(:include, :include=)
end
end
end
end

0 comments on commit 1c3dbd6

Please sign in to comment.