diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index cb61749082..2fd1e40e9f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -655,16 +655,6 @@ Style/RedundantFreeze: Exclude: - 'app/helpers/blacklight/render_partials_helper_behavior.rb' -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, AllowInnerSlashes. -# SupportedStyles: slashes, percent_r, mixed -Style/RegexpLiteral: - Exclude: - - 'app/views/catalog/_document.atom.builder' - - 'spec/helpers/blacklight/url_helper_behavior_spec.rb' - - 'spec/views/catalog/_thumbnail.html.erb_spec.rb' - # Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/app/views/catalog/_document.atom.builder b/app/views/catalog/_document.atom.builder index 1d97d67066..c87a71065d 100644 --- a/app/views/catalog/_document.atom.builder +++ b/app/views/catalog/_document.atom.builder @@ -2,22 +2,21 @@ xml.entry do xml.title index_presenter(document).label(document_show_link_field(document)) - + # updated is required, for now we'll just set it to now, sorry xml.updated Time.current.iso8601 - + xml.link "rel" => "alternate", "type" => "text/html", "href" => polymorphic_url(url_for_document(document)) # add other doc-specific formats, atom only lets us have one per # content type, so the first one in the list wins. - xml << show_presenter(document).link_rel_alternates(unique: true) - + xml << show_presenter(document).link_rel_alternates(unique: true) + xml.id polymorphic_url(url_for_document(document)) - - + if document.to_semantic_values.key? :author xml.author { xml.name(document.to_semantic_values[:author].first) } end - + with_format("html") do xml.summary "type" => "html" do xml.text! render_document_partial(document, @@ -25,23 +24,23 @@ xml.entry do document_counter: document_counter) end end - - #If they asked for a format, give it to them. + + #If they asked for a format, give it to them. if (params["content_format"] && document.export_formats[params["content_format"].to_sym]) - + type = document.export_formats[params["content_format"].to_sym][:content_type] - + xml.content type: type do |content_element| data = document.export_as(params["content_format"]) - + # encode properly. See: # http://tools.ietf.org/html/rfc4287#section-4.1.3.3 type = type.downcase - if (type.downcase =~ /\+|\/xml$/) - # xml, just put it right in + if (type.downcase =~ %r{\+|/xml$}) + # xml, just put it right in content_element << data - elsif (type.downcase =~ /text\//) + elsif (type.downcase =~ %r{text/}) # text, escape content_element.text! data else @@ -49,6 +48,6 @@ xml.entry do content_element << Base64.encode64(data) end end - + end end diff --git a/spec/helpers/blacklight/url_helper_behavior_spec.rb b/spec/helpers/blacklight/url_helper_behavior_spec.rb index 31704f3ad9..6d0f1433c0 100644 --- a/spec/helpers/blacklight/url_helper_behavior_spec.rb +++ b/spec/helpers/blacklight/url_helper_behavior_spec.rb @@ -85,7 +85,7 @@ allow(helper).to receive(:current_search_session).and_return double(query_params: bookmarks_query_params) tag = helper.link_back_to_catalog expect(tag).to match /Back to Bookmarks/ - expect(tag).to match /\/bookmarks/ + expect(tag).to match %r{/bookmarks} end context "with a search context" do @@ -152,7 +152,7 @@ allow(helper).to receive_messages(params: parameter_class.new) tag = helper.link_to_query(query) expect(tag).to match /q=#{query}/ - expect(tag).to match />#{query}<\/a>/ + expect(tag).to match %r{>#{query}} end it "builds a link tag to catalog using query string and other existing params" do diff --git a/spec/views/catalog/_thumbnail.html.erb_spec.rb b/spec/views/catalog/_thumbnail.html.erb_spec.rb index 2f8389f20f..8165f22427 100644 --- a/spec/views/catalog/_thumbnail.html.erb_spec.rb +++ b/spec/views/catalog/_thumbnail.html.erb_spec.rb @@ -27,7 +27,7 @@ it "renders the thumbnail if the document has one" do render partial: "catalog/thumbnail", locals: { document: document_with_thumbnail_field, document_counter: 1 } expect(rendered).to match /document-thumbnail/ - expect(rendered).to match /src="http:\/\/localhost\/logo.png"/ + expect(rendered).to match %r{src="http://localhost/logo.png"} end it "does not render a thumbnail if the document does not have one" do