mirror of
https://github.com/CodeforLeipzig/stadtratmonitor.git
synced 2024-12-22 15:43:14 +01:00
Fix search bug
This commit is contained in:
parent
3111422940
commit
4a9be9c579
3 changed files with 13 additions and 9 deletions
|
@ -1,8 +1,6 @@
|
||||||
# Stadtratmonitor
|
# Stadtratmonitor
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/CodeforLeipzig/stadtratmonitor.png?branch=master)](https://travis-ci.org/CodeforLeipzig/stadtratmonitor) [![Coverage Status](https://coveralls.io/repos/github/CodeforLeipzig/stadtratmonitor/badge.svg?branch=master)](https://coveralls.io/github/CodeforLeipzig/stadtratmonitor?branch=master) [![Code Climate](https://codeclimate.com/github/CodeforLeipzig/stadtratmonitor/badges/gpa.svg)](https://codeclimate.com/github/CodeforLeipzig/stadtratmonitor)
|
[![Build Status](https://travis-ci.org/CodeforLeipzig/stadtratmonitor.png?branch=master)](https://travis-ci.org/CodeforLeipzig/stadtratmonitor) [![Coverage Status](https://coveralls.io/repos/github/CodeforLeipzig/stadtratmonitor/badge.svg?branch=master)](https://coveralls.io/github/CodeforLeipzig/stadtratmonitor?branch=master)
|
||||||
[![Dependency Status](https://gemnasium.com/badges/github.com/CodeforLeipzig/stadtratmonitor.svg)](https://gemnasium.com/github.com/CodeforLeipzig/stadtratmonitor)
|
|
||||||
[![Stories in Ready](https://badge.waffle.io/CodeforLeipzig/stadtratmonitor.png?label=ready&title=Ready)](http://waffle.io/CodeforLeipzig/stadtratmonitor)
|
|
||||||
|
|
||||||
**Offical site:** https://stadtratmonitor.leipzig.codefor.de/
|
**Offical site:** https://stadtratmonitor.leipzig.codefor.de/
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ class SearchController < ApplicationController
|
||||||
@papers.each do |paper|
|
@papers.each do |paper|
|
||||||
unless paper.reference.nil? && paper.reference.contains("-")
|
unless paper.reference.nil? && paper.reference.contains("-")
|
||||||
segments = paper.reference.split("-")
|
segments = paper.reference.split("-")
|
||||||
id = (paper.reference.start_with?("VI-") && segments.count > 2 ?
|
id = ((paper.reference.start_with?("VI-") || paper.reference.start_with?("VII-")) && segments.count > 2 ?
|
||||||
segments[2] : segments[1])
|
segments[2] : segments[1])
|
||||||
escaped_chars = Regexp.escape('\\+-*:()[]{}&!?^|\/')
|
escaped_chars = Regexp.escape('\\+-*:()[]{}&!?^|\/')
|
||||||
sanitized_id = id.gsub(/([#{escaped_chars}])/, '\\\\\1')
|
sanitized_id = id.gsub(/([#{escaped_chars}])/, '\\\\\1')
|
||||||
|
@ -47,7 +47,7 @@ class SearchController < ApplicationController
|
||||||
|
|
||||||
sort do
|
sort do
|
||||||
by :published_at, order: 'desc'
|
by :published_at, order: 'desc'
|
||||||
by :reference, order: 'asc'
|
by :reference, order: 'desc'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@sub_papers = Paper.search(@sub_search_definition)
|
@sub_papers = Paper.search(@sub_search_definition)
|
||||||
|
|
|
@ -108,7 +108,8 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
|
||||||
|
|
||||||
resultSubEntries = resultEntry.find("ul").all("li")
|
resultSubEntries = resultEntry.find("ul").all("li")
|
||||||
linkName2 = getLinkName(newPaper)
|
linkName2 = getLinkName(newPaper)
|
||||||
expect(resultSubEntries[1]).to have_link(linkName2, href: newPaper.url)
|
expect(resultSubEntries[0]).to have_link(linkName2, href: newPaper.url)
|
||||||
|
expect(resultSubEntries[1]).to have_link(linkName1, href: mainPaper.url)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Papers with common reference id in search result ordered by ref" do
|
scenario "Papers with common reference id in search result ordered by ref" do
|
||||||
|
@ -125,9 +126,11 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
|
||||||
|
|
||||||
resultSubEntries = resultEntry.find("ul").all("li")
|
resultSubEntries = resultEntry.find("ul").all("li")
|
||||||
linkName1 = getLinkName(newPaper1)
|
linkName1 = getLinkName(newPaper1)
|
||||||
expect(resultSubEntries[2]).to have_link(linkName1, href: newPaper1.url)
|
expect(resultSubEntries[0]).to have_link(linkName1, href: newPaper1.url)
|
||||||
linkName2 = getLinkName(newPaper2)
|
linkName2 = getLinkName(newPaper2)
|
||||||
expect(resultSubEntries[1]).to have_link(linkName2, href: newPaper2.url)
|
expect(resultSubEntries[1]).to have_link(linkName2, href: newPaper2.url)
|
||||||
|
linkName3 = getLinkName(mainPaper)
|
||||||
|
expect(resultSubEntries[2]).to have_link(linkName3, href: mainPaper.url)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Papers with common reference id handled also for missing prefix" do
|
scenario "Papers with common reference id handled also for missing prefix" do
|
||||||
|
@ -144,9 +147,11 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
|
||||||
|
|
||||||
resultSubEntries = resultEntry.find("ul").all("li")
|
resultSubEntries = resultEntry.find("ul").all("li")
|
||||||
linkName1 = getLinkName(newPaper1)
|
linkName1 = getLinkName(newPaper1)
|
||||||
expect(resultSubEntries[2]).to have_link(linkName1, href: newPaper1.url)
|
expect(resultSubEntries[0]).to have_link(linkName1, href: newPaper1.url)
|
||||||
linkName2 = getLinkName(newPaper1Change)
|
linkName2 = getLinkName(newPaper1Change)
|
||||||
expect(resultSubEntries[1]).to have_link(linkName2, href: newPaper1Change.url)
|
expect(resultSubEntries[1]).to have_link(linkName2, href: newPaper1Change.url)
|
||||||
|
linkName3 = getLinkName(mainPaper)
|
||||||
|
expect(resultSubEntries[2]).to have_link(linkName3, href: mainPaper.url)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Finds 'Testen' with search 'Test'" do
|
scenario "Finds 'Testen' with search 'Test'" do
|
||||||
|
@ -227,7 +232,8 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
|
||||||
|
|
||||||
resultSubEntries = resultEntry.find("ul").all("li")
|
resultSubEntries = resultEntry.find("ul").all("li")
|
||||||
linkName2 = getLinkName(newPaper)
|
linkName2 = getLinkName(newPaper)
|
||||||
expect(resultSubEntries[1]).to have_link(linkName2, href: newPaper.url)
|
expect(resultSubEntries[0]).to have_link(linkName2, href: newPaper.url)
|
||||||
|
expect(resultSubEntries[1]).to have_link(linkName1, href: mainPaper.url)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue