Skip to content

Commit

Permalink
Add searched? method
Browse files Browse the repository at this point in the history
  • Loading branch information
mashiro committed Aug 21, 2012
1 parent 6b648d7 commit bbe3fdb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/kashiwamochi/query.rb
Expand Up @@ -105,5 +105,9 @@ def inspect
def persisted?
false
end

def searched?
!@search_params.empty? || !@sort_params.empty?
end
end
end
14 changes: 14 additions & 0 deletions spec/kashiwamochi/query_spec.rb
Expand Up @@ -90,6 +90,20 @@
end
end

describe '#searched?' do
context 'with query' do
before { @q = Kashiwamochi::Query.new(:name => 'aira', :s => ["created_at desc"]) }
subject { @q }
it { should be_searched }
end

context 'without query' do
before { @q = Kashiwamochi::Query.new }
subject { @q }
it { should_not be_searched }
end
end

describe '#to_option' do
before { @q = Kashiwamochi::Query.new(:name => 'aira', :s => ["created_at desc"]) }
subject { @q.to_option }
Expand Down

0 comments on commit bbe3fdb

Please sign in to comment.