Skip to content

Commit

Permalink
Merge pull request #1484 from projectblacklight/no_escape
Browse files Browse the repository at this point in the history
Update examples that no longer rely on escaping
  • Loading branch information
cbeer committed Sep 6, 2016
2 parents f5f7d2b + b9cdaa9 commit d34300d
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions spec/models/blacklight/solr/search_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@

it "should pass integer-like strings through" do
expect(subject.send(:facet_value_to_fq_string, "facet_name", "1")).to eq '{!term f=facet_name}1'
expect(subject.send(:facet_value_to_fq_string, "facet_name", -1)).to eq '{!term f=facet_name}-1'
end

it "should pass floats through" do
Expand All @@ -387,26 +388,19 @@
expect(subject.send(:facet_value_to_fq_string, "facet_name", "1.11")).to eq '{!term f=facet_name}1.11'
end

it "should escape negative integers" do
expect(subject.send(:facet_value_to_fq_string, "facet_name", -1)).to eq '{!term f=facet_name}-1'
end

it "should pass date-type fields through" do
allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:date => true, :query => nil, :tag => nil, :field => 'facet_name'))

expect(subject.send(:facet_value_to_fq_string, "facet_name", "2012-01-01")).to eq '{!term f=facet_name}2012-01-01'
end

it "should escape datetime-type fields" do
allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:date => true, :query => nil, :tag => nil, :field => 'facet_name'))
context 'date handling' do
before { allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:date => true, :query => nil, :tag => nil, :field => 'facet_name')) }

expect(subject.send(:facet_value_to_fq_string, "facet_name", "2003-04-09T00:00:00Z")).to eq '{!term f=facet_name}2003-04-09T00:00:00Z'
end
it "should pass date-type fields through" do
expect(subject.send(:facet_value_to_fq_string, "facet_name", "2012-01-01")).to eq '{!term f=facet_name}2012-01-01'
expect(subject.send(:facet_value_to_fq_string, "facet_name", "2003-04-09T00:00:00Z")).to eq '{!term f=facet_name}2003-04-09T00:00:00Z'
end

it "should format Date objects correctly" do
allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:date => nil, :query => nil, :tag => nil, :field => 'facet_name'))
d = DateTime.parse("2003-04-09T00:00:00")
expect(subject.send(:facet_value_to_fq_string, "facet_name", d)).to eq '{!term f=facet_name}2003-04-09T00:00:00Z'
it "should format Date objects correctly" do
allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:date => nil, :query => nil, :tag => nil, :field => 'facet_name'))
d = DateTime.parse("2003-04-09T00:00:00")
expect(subject.send(:facet_value_to_fq_string, "facet_name", d)).to eq '{!term f=facet_name}2003-04-09T00:00:00Z'
end
end

it "should handle range requests" do
Expand Down

0 comments on commit d34300d

Please sign in to comment.