diff --git a/README.md b/README.md index e0fb472..259139e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # 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) -[![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) +[![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) **Offical site:** https://stadtratmonitor.leipzig.codefor.de/ diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index c138635..775022e 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -28,7 +28,7 @@ class SearchController < ApplicationController @papers.each do |paper| unless paper.reference.nil? && paper.reference.contains("-") 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]) escaped_chars = Regexp.escape('\\+-*:()[]{}&!?^|\/') sanitized_id = id.gsub(/([#{escaped_chars}])/, '\\\\\1') @@ -47,7 +47,7 @@ class SearchController < ApplicationController sort do by :published_at, order: 'desc' - by :reference, order: 'asc' + by :reference, order: 'desc' end end @sub_papers = Paper.search(@sub_search_definition) diff --git a/spec/features/basic_search_spec.rb b/spec/features/basic_search_spec.rb index 5edcc73..3cae8fc 100644 --- a/spec/features/basic_search_spec.rb +++ b/spec/features/basic_search_spec.rb @@ -108,7 +108,8 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do resultSubEntries = resultEntry.find("ul").all("li") 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 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") 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) expect(resultSubEntries[1]).to have_link(linkName2, href: newPaper2.url) + linkName3 = getLinkName(mainPaper) + expect(resultSubEntries[2]).to have_link(linkName3, href: mainPaper.url) end 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") 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) expect(resultSubEntries[1]).to have_link(linkName2, href: newPaper1Change.url) + linkName3 = getLinkName(mainPaper) + expect(resultSubEntries[2]).to have_link(linkName3, href: mainPaper.url) end 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") 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