-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #912 from projecthydra/fix_query_nil
query for nil creates correct query
- Loading branch information
Showing
9 changed files
with
258 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require 'spec_helper' | ||
|
||
describe ActiveFedora::FinderMethods do | ||
let(:object_class) do | ||
Class.new do | ||
def self.delegated_attributes | ||
{} | ||
end | ||
end | ||
end | ||
|
||
let(:finder_class) do | ||
this = self | ||
Class.new do | ||
include ActiveFedora::FinderMethods | ||
@@klass = this.object_class | ||
def initialize | ||
@klass = @@klass | ||
end | ||
end | ||
end | ||
|
||
let(:finder) { finder_class.new } | ||
|
||
describe "#condition_to_clauses" do | ||
subject { finder.send(:condition_to_clauses, key, value) } | ||
let(:key) { 'library_id' } | ||
|
||
context "when value is nil" do | ||
let(:value) { nil } | ||
it { is_expected.to eq "-library_id:[* TO *]" } | ||
end | ||
|
||
context "when value is empty string" do | ||
let(:value) { '' } | ||
it { is_expected.to eq "-library_id:[* TO *]" } | ||
end | ||
|
||
context "when value is an id" do | ||
let(:value) { 'one/two/three' } | ||
it { is_expected.to eq "_query_:\"{!raw f=library_id}one/two/three\"" } | ||
end | ||
|
||
context "when value is an array" do | ||
let(:value) { ['one', 'four'] } | ||
it { is_expected.to eq "_query_:\"{!raw f=library_id}one\" AND " \ | ||
"_query_:\"{!raw f=library_id}four\"" } | ||
end | ||
end | ||
end |
Oops, something went wrong.