]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/2280'
authorTom Hughes <tom@compton.nu>
Wed, 26 Jun 2019 18:57:12 +0000 (19:57 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 26 Jun 2019 18:57:12 +0000 (19:57 +0100)
49 files changed:
.rubocop_todo.yml
app/controllers/api/traces_controller.rb
app/controllers/api/users_controller.rb
app/controllers/changesets_controller.rb
app/controllers/site_controller.rb
app/helpers/application_helper.rb
app/helpers/changesets_helper.rb
app/helpers/note_helper.rb
app/helpers/user_blocks_helper.rb
app/models/trace.rb
app/views/api/changesets/changeset.builder
app/views/api/changesets/changesets.builder
app/views/api/notes/_comment.html.erb
app/views/api/notes/index.gpx.builder
app/views/api/notes/index.json.jsonify
app/views/api/notes/index.rss.builder
app/views/api/notes/index.xml.builder
app/views/api/notes/show.gpx.builder
app/views/api/notes/show.json.jsonify
app/views/api/notes/show.rss.builder
app/views/api/notes/show.xml.builder
app/views/api/traces/_trace.builder [new file with mode: 0644]
app/views/api/traces/show.builder [new file with mode: 0644]
app/views/api/users/gpx_files.builder [new file with mode: 0644]
app/views/api/users/index.builder
app/views/api/users/show.builder
app/views/browse/_common_details.html.erb
app/views/browse/changeset.html.erb
app/views/changeset_comments/_comment.html.erb
app/views/changesets/index.atom.builder
app/views/changesets/index.html.erb
app/views/diary_entries/_diary_index_entry.html.erb [deleted file]
app/views/diary_entries/comments.html.erb
app/views/diary_entries/index.html.erb
app/views/diary_entries/show.html.erb
app/views/issues/index.html.erb
app/views/notes/mine.html.erb
app/views/redactions/_redactions.html.erb [deleted file]
app/views/redactions/index.html.erb
app/views/traces/_trace.html.erb
app/views/traces/index.html.erb
app/views/user_blocks/revoke.html.erb
app/views/user_blocks/show.html.erb
app/views/users/_contact.html.erb
app/views/users/index.html.erb
config/locales/en.yml
test/controllers/api/traces_controller_test.rb
test/helpers/note_helper_test.rb
test/helpers/user_roles_helper_test.rb

index 26b5aa64b8402baec153a5c6358fe5b37c596b3c..4d772ed6eace4b65c868bfb15956292dacf95d3c 100644 (file)
@@ -193,4 +193,4 @@ Style/NumericLiterals:
 # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
 # URISchemes: http, https
 Metrics/LineLength:
-  Max: 1073
+  Max: 307
index 86f1370f64d8e1d7198c3bb64e17ba7a6c13f24e..8979704a71802167af2b374ea8f173259bd36215 100644 (file)
@@ -16,13 +16,9 @@ module Api
     around_action :api_call_handle_error
 
     def show
-      trace = Trace.visible.find(params[:id])
+      @trace = Trace.visible.find(params[:id])
 
-      if trace.public? || trace.user == current_user
-        render :xml => trace.to_xml.to_s
-      else
-        head :forbidden
-      end
+      head :forbidden unless @trace.public? || @trace.user == current_user
     end
 
     def update
index 3180cabccc7cac28ab8c51b808762a55116b58d9..d3387bd5ffaaa1f48a0e32dff1b32d25ae3eb639 100644 (file)
@@ -13,7 +13,7 @@ module Api
 
     def show
       if @user.visible?
-        render :action => :show, :content_type => "text/xml"
+        render :content_type => "text/xml"
       else
         head :gone
       end
@@ -33,15 +33,12 @@ module Api
 
       @users = User.visible.find(ids)
 
-      render :action => :index, :content_type => "text/xml"
+      render :content_type => "text/xml"
     end
 
     def gpx_files
-      doc = OSM::API.new.get_xml_doc
-      current_user.traces.reload.each do |trace|
-        doc.root << trace.to_xml_node
-      end
-      render :xml => doc.to_s
+      @traces = current_user.traces.reload
+      render :content_type => "application/xml"
     end
 
     private
index 82966a353437d1d0a0837b527d1583c9798f11ca..5b6d3e010db0e5ea89d290eb71e28856a70af3bb 100644 (file)
@@ -60,7 +60,7 @@ class ChangesetsController < ApplicationController
 
       changesets = changesets.where("changesets.id <= ?", @params[:max_id]) if @params[:max_id]
 
-      @edits = changesets.order("changesets.id DESC").limit(20).preload(:user, :changeset_tags, :comments)
+      @changesets = changesets.order("changesets.id DESC").limit(20).preload(:user, :changeset_tags, :comments)
 
       render :action => :index, :layout => false
     end
index 471e9f3c5636d75d54765fc2854919e9a4da11e1..57ac075010fd837609a4170ab96883c78ff83c3d 100644 (file)
@@ -126,7 +126,7 @@ class SiteController < ApplicationController
       :style_src => %w['unsafe-inline']
     )
 
-    render "id", :layout => false
+    render :layout => false
   end
 
   private
index c78c3ea46423227e62db5a69b01633c714f0cb68..0f2c862e6b60a212a21b541c7b76a6c921141cbe 100644 (file)
@@ -49,6 +49,10 @@ module ApplicationHelper
     content_tag(:span, time_ago_in_words(date), :title => l(date, :format => :friendly))
   end
 
+  def friendly_date_ago(date)
+    content_tag(:span, time_ago_in_words(date, :scope => :'datetime.distance_in_words_ago'), :title => l(date, :format => :friendly))
+  end
+
   def body_class
     if content_for? :body_class
       content_for :body_class
index 4a327c16c158139d1cb7e62d956449263b6a112f..97a70f7898b9f4f1d1f5d26c8ae5c41b3dc9f737 100644 (file)
@@ -12,11 +12,11 @@ module ChangesetsHelper
   def changeset_details(changeset)
     if changeset.closed_at > Time.now
       action = :created
-      time = distance_of_time_in_words_to_now(changeset.created_at)
+      time = time_ago_in_words(changeset.created_at, :scope => :'datetime.distance_in_words_ago')
       title = l(changeset.created_at)
     else
       action = :closed
-      time = distance_of_time_in_words_to_now(changeset.closed_at)
+      time = time_ago_in_words(changeset.closed_at, :scope => :'datetime.distance_in_words_ago')
       title = "#{t('browse.created')}: #{l(changeset.created_at)}&#10;#{t('browse.closed')}: #{l(changeset.closed_at)}".html_safe
     end
 
index 4b5be42d78b8786988be869e4dc5d2b5ca3c1901..dbe0c89f78e0f687f65934070b68f4ac94f1d6d4 100644 (file)
@@ -2,11 +2,11 @@ module NoteHelper
   def note_event(event, at, by)
     if by.nil?
       I18n.t("browse.note." + event + "_by_anonymous",
-             :when => friendly_date(at),
+             :when => friendly_date_ago(at),
              :exact_time => l(at)).html_safe
     else
       I18n.t("browse.note." + event + "_by",
-             :when => friendly_date(at),
+             :when => friendly_date_ago(at),
              :exact_time => l(at),
              :user => note_author(by)).html_safe
     end
index ed9997f6d778f7744a66d8ab02abe3c28c6ddb1d..9f0c4a3040abd98196195d850d55857ed72fe15e 100644 (file)
@@ -19,7 +19,7 @@ module UserBlocksHelper
       # either because the user viewed the block (updated_at) or it expired or was
       # revoked (ends_at)
       last_time = [block.ends_at, block.updated_at].max
-      I18n.t("user_blocks.helper.time_past", :time => friendly_date(last_time)).html_safe
+      I18n.t("user_blocks.helper.time_past", :time => friendly_date_ago(last_time)).html_safe
     end
   end
 
index 9d710d1ceca99b540065aa6822be470c40cb3702..adaba52ae23b87b301598f5d32e26dc8787224e7 100644 (file)
@@ -164,36 +164,6 @@ class Trace < ActiveRecord::Base
     extension
   end
 
-  def to_xml
-    doc = OSM::API.new.get_xml_doc
-    doc.root << to_xml_node
-    doc
-  end
-
-  def to_xml_node
-    el1 = XML::Node.new "gpx_file"
-    el1["id"] = id.to_s
-    el1["name"] = name.to_s
-    el1["lat"] = latitude.to_s if inserted
-    el1["lon"] = longitude.to_s if inserted
-    el1["user"] = user.display_name
-    el1["visibility"] = visibility
-    el1["pending"] = inserted ? "false" : "true"
-    el1["timestamp"] = timestamp.xmlschema
-
-    el2 = XML::Node.new "description"
-    el2 << description
-    el1 << el2
-
-    tags.each do |tag|
-      el2 = XML::Node.new("tag")
-      el2 << tag.tag
-      el1 << el2
-    end
-
-    el1
-  end
-
   def update_from_xml(xml, create = false)
     p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
     doc = p.parse
index e8da4006f531b71349b32831c03f2f2036ba87f8..cedfc81ea5ce34310cac041136bf9d5a39030f4f 100644 (file)
@@ -3,5 +3,5 @@ xml.instruct! :xml, :version => "1.0"
 # basic attributes
 
 xml.osm(OSM::API.new.xml_root_attributes) do |osm|
-  osm << render(:partial => "api/changesets/changeset.builder", :locals => { :changeset => @changeset })
+  osm << render(@changeset)
 end
index da434f1f45192dda39497cb05ecf1de43fc03ec7..c68a76da3bcf5da5746f2f28e7a61d9dc4b42cfb 100644 (file)
@@ -4,6 +4,6 @@ xml.instruct! :xml, :version => "1.0"
 
 xml.osm(OSM::API.new.xml_root_attributes) do |osm|
   @changesets.each do |changeset|
-    osm << render(:partial => "api/changesets/changeset.builder", :locals => { :changeset => changeset })
+    osm << render(changeset)
   end
 end
index d9c17848b26995f00abbd91f9e4fca25b943db84..f599eec1417366d78f0cb6f8d173e6798789d998 100644 (file)
@@ -1,8 +1,8 @@
 <div class="note-comment" style="margin-top: 5px">
   <% if comment.author.nil? -%>
-  <div class="note-comment-description" style="font-size: smaller; color: #999999"><%= t ".#{comment.event}_at_html", :when => friendly_date(comment.created_at) %></div>
+  <div class="note-comment-description" style="font-size: smaller; color: #999999"><%= t ".#{comment.event}_at_html", :when => friendly_date_ago(comment.created_at) %></div>
   <% else -%>
-  <div class="note-comment-description" style="font-size: smaller; color: #999999"><%= t ".#{comment.event}_at_by_html", :when => friendly_date(comment.created_at), :user => note_author(comment.author, :only_path => false) %></div>
+  <div class="note-comment-description" style="font-size: smaller; color: #999999"><%= t ".#{comment.event}_at_by_html", :when => friendly_date_ago(comment.created_at), :user => note_author(comment.author, :only_path => false) %></div>
   <% end -%>
   <div class="note-comment-text"><%= comment.body %></div>
 </div>
index 58da357da5f6daa688ed27de65f333c2c83b9858..d737752bf2cbc3eacf2d9531e858ab34e00155d0 100644 (file)
@@ -5,5 +5,5 @@ xml.gpx("version" => "1.1",
         "xmlns" => "http://www.topografix.com/GPX/1/1",
         "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
         "xsi:schemaLocation" => "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd") do
-  xml << (render(:partial => "note", :collection => @notes) || "")
+  xml << (render(@notes) || "")
 end
index cb75d41c4093d477d9c75367277aea2f8708abe7..bfc8ffcf854f3ed87c9569d05168462c8d52a725 100644 (file)
@@ -1,5 +1,5 @@
 json.type "FeatureCollection"
 
 json.features(@notes) do |note|
-  json.ingest! render(:partial => "note", :object => note)
+  json.ingest! render(note)
 end
index 96ba4b73412cb5ddc3bd496ce01b442607150d0c..95ea0b3b11394ca7a2b76b8b8dc6776ed19c7b14 100644 (file)
@@ -9,6 +9,6 @@ xml.rss("version" => "2.0",
     xml.description t("api.notes.rss.description_area", :min_lat => @min_lat, :min_lon => @min_lon, :max_lat => @max_lat, :max_lon => @max_lon)
     xml.link url_for(:controller => "/site", :action => "index", :only_path => false)
 
-    xml << (render(:partial => "note", :collection => @notes) || "")
+    xml << (render(@notes) || "")
   end
 end
index 286b1e1ccecd0b8513e77d41bc442aff826e21a1..ebb026e651396a5d8263e1a824feccbbe5023c13 100644 (file)
@@ -1,5 +1,5 @@
 xml.instruct!
 
 xml.osm(OSM::API.new.xml_root_attributes) do |osm|
-  osm << (render(:partial => "note", :collection => @notes) || "")
+  osm << (render(@notes) || "")
 end
index f87ff4dd947ba2f8f323287e6a9916cbe04644d0..750d01f562a4265e2a08dd934913b629e12275cd 100644 (file)
@@ -5,5 +5,5 @@ xml.gpx("version" => "1.1",
         "xmlns" => "http://www.topografix.com/GPX/1/1",
         "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
         "xsi:schemaLocation" => "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd") do
-  xml << render(:partial => "note", :object => @note)
+  xml << render(@note)
 end
index 3e5685fc0089e42a9891ab4f79e2c57fce7dbd9e..10d127291fcf5ef57eb167827f9fd1931a8cd027 100644 (file)
@@ -1 +1 @@
-json.ingest! render(:partial => "note", :object => @note)
+json.ingest! render(@note)
index 61ee0857a456562052e1186f75d53ed10e81f8df..d739ea6d998cc778862d8a7003550c152680b24a 100644 (file)
@@ -8,6 +8,6 @@ xml.rss("version" => "2.0",
     xml.description t("api.notes.rss.description_item", :id => @note.id)
     xml.link url_for(:controller => "/site", :action => "index", :only_path => false)
 
-    xml << render(:partial => "note", :object => @note)
+    xml << render(@note)
   end
 end
index 51b3daebd330db43c1cae2036a4efcff42cf2781..bb87fe76298ccb57efa6c6685b5a003cc59902b0 100644 (file)
@@ -1,5 +1,5 @@
 xml.instruct!
 
 xml.osm(OSM::API.new.xml_root_attributes) do |osm|
-  osm << render(:partial => "note", :object => @note)
+  osm << render(@note)
 end
diff --git a/app/views/api/traces/_trace.builder b/app/views/api/traces/_trace.builder
new file mode 100644 (file)
index 0000000..7efd640
--- /dev/null
@@ -0,0 +1,22 @@
+# basic attributes
+
+attrs = {
+  "id" => trace.id,
+  "name" => trace.name,
+  "user" => trace.user.display_name,
+  "visibility" => trace.visibility,
+  "pending" => trace.inserted ? "false" : "true",
+  "timestamp" => trace.timestamp.xmlschema
+}
+
+if trace.inserted
+  attrs["lat"] = trace.latitude.to_s
+  attrs["lon"] = trace.longitude.to_s
+end
+
+xml.gpx_file(attrs) do |trace_xml_node|
+  trace_xml_node.description(trace.description)
+  trace.tags.each do |t|
+    trace_xml_node.tag(t.tag)
+  end
+end
diff --git a/app/views/api/traces/show.builder b/app/views/api/traces/show.builder
new file mode 100644 (file)
index 0000000..f4a4e4d
--- /dev/null
@@ -0,0 +1,5 @@
+xml.instruct! :xml, :version => "1.0"
+
+xml.osm(OSM::API.new.xml_root_attributes) do |osm|
+  osm << render(@trace)
+end
diff --git a/app/views/api/users/gpx_files.builder b/app/views/api/users/gpx_files.builder
new file mode 100644 (file)
index 0000000..d5287ff
--- /dev/null
@@ -0,0 +1,7 @@
+xml.instruct! :xml, :version => "1.0"
+
+xml.osm(OSM::API.new.xml_root_attributes) do |osm|
+  @traces.each do |trace|
+    osm << render(:partial => "api/traces/trace", :locals => { :trace => trace })
+  end
+end
index 68d629099f45177b13242a24d8bdb2cd9a1cd7fd..60fcfa898efbe8aa2068d9b0dbef2f9d52cae4c5 100644 (file)
@@ -1,4 +1,4 @@
 xml.instruct! :xml, :version => "1.0"
 xml.osm(OSM::API.new.xml_root_attributes) do |osm|
-  osm << render(:partial => "user", :collection => @users)
+  osm << render(@users)
 end
index dd5e9368920c936931fd022c3a98eef115b34976..96bfdd3fa9d0007313952c29b435becdb0fb4465 100644 (file)
@@ -1,4 +1,4 @@
 xml.instruct! :xml, :version => "1.0"
 xml.osm(OSM::API.new.xml_root_attributes) do |osm|
-  osm << render(:partial => "user", :object => @user)
+  osm << render(@user)
 end
index 44bbe04f8c1ec408e50e24c0092bc8a1892e9ff7..1c8f1c5da4293105c06200e2b29647b8395a7d05 100644 (file)
@@ -8,7 +8,7 @@
 
 <div class="details">
   <%= t "browse.#{common_details.visible? ? :edited : :deleted}_by_html",
-        :time => distance_of_time_in_words_to_now(common_details.timestamp),
+        :time => time_ago_in_words(common_details.timestamp, :scope => :'datetime.distance_in_words_ago'),
         :user => changeset_user_link(common_details.changeset),
         :title => l(common_details.timestamp) %>
 </div>
index d52a4742613f2e224f1bea067fb07d0513108eda..9ad35b2a7d5c71bba58a14854a49a01f56edf7c2 100644 (file)
@@ -36,7 +36,7 @@
               <li id="c<%= comment.id %>">
                 <small class='deemphasize'>
                   <%= t(".commented_by",
-                        :when => friendly_date(comment.created_at),
+                        :when => friendly_date_ago(comment.created_at),
                         :exact_time => l(comment.created_at),
                         :user => link_to(h(comment.author.display_name), user_path(comment.author))).html_safe %>
                   <% if current_user and current_user.moderator? %>
@@ -49,7 +49,7 @@
               <li id="c<%= comment.id %>">
                 <small class='deemphasize'>
                   <%= t(".hidden_commented_by",
-                        :when => friendly_date(comment.created_at),
+                        :when => friendly_date_ago(comment.created_at),
                         :exact_time => l(comment.created_at),
                         :user => link_to(h(comment.author.display_name), user_path(comment.author))).html_safe %>
                   â€” <span class="action-button deemphasize" data-comment-id="<%= comment.id %>" data-method="POST" data-url="<%= changeset_comment_unhide_url(comment.id) %>"><%= t("javascripts.changesets.show.unhide_comment") %></span>
index 3b8314decf28c6b082aef69dc0175757dc759034..a312e4f0f06d6e9db68a222bd48fce4b1cc9e543 100644 (file)
@@ -2,6 +2,6 @@
           :author => comment.author.display_name,
           :changeset_id => comment.changeset.id.to_s %></h2>
 <div class="changeset-comment" style="margin-top: 5px">
-  <div class="changeset-comment-description" style="font-size: smaller; color: #999999"><%= t ".commented_at_by_html", :when => friendly_date(comment.created_at), :user => comment.author.display_name %></div>
+  <div class="changeset-comment-description" style="font-size: smaller; color: #999999"><%= t ".commented_at_by_html", :when => friendly_date_ago(comment.created_at), :user => comment.author.display_name %></div>
   <div class="changeset-comment-text"><%= comment.body %></div>
 </div>
index 05d9ab68ac306cf28830b714a70488ab97a8582c..b1fbd6992aa14c3ddd4d2e9c65a7c9bc9621093f 100644 (file)
@@ -4,7 +4,7 @@ atom_feed(:language => I18n.locale, :schema_date => 2009,
           "xmlns:georss" => "http://www.georss.org/georss") do |feed|
   feed.title changeset_index_title(params, current_user)
 
-  feed.updated @edits.map { |e| [e.created_at, e.closed_at].max }.max
+  feed.updated @changesets.map { |e| [e.created_at, e.closed_at].max }.max
   feed.icon image_url("favicon.ico")
   feed.logo image_url("mag_map-rss2.0.png")
 
@@ -14,7 +14,7 @@ atom_feed(:language => I18n.locale, :schema_date => 2009,
     end
   end
 
-  @edits.each do |changeset|
+  @changesets.each do |changeset|
     feed.entry(changeset, :updated => changeset.closed_at, :id => changeset_url(changeset.id, :only_path => false)) do |entry|
       entry.link :rel => "alternate",
                  :href => changeset_show_url(changeset, :only_path => false),
index 1ce98301a3145bedd94c3b5ed0f1efaa1567d2f6..1e3daa081e4cf3acc8dffced758d8f970d3fe338 100644 (file)
@@ -1,10 +1,10 @@
-<% if @edits.present? %>
+<% if @changesets.present? %>
   <ol class="changesets">
-    <%= render :partial => "changeset", :collection => @edits %>
+    <%= render @changesets %>
   </ol>
-<% if @edits.size == 20 -%>
+<% if @changesets.size == 20 -%>
   <div class="changeset_more">
-    <%= link_to t(".load_more"), url_for(@params.merge(:max_id => @edits.last.id - 1)), :class => "button load_more" %>
+    <%= link_to t(".load_more"), url_for(@params.merge(:max_id => @changesets.last.id - 1)), :class => "button load_more" %>
     <div class="loader"><%= image_tag "searching.gif" %></div>
   </div>
 <% end -%>
diff --git a/app/views/diary_entries/_diary_index_entry.html.erb b/app/views/diary_entries/_diary_index_entry.html.erb
deleted file mode 100644 (file)
index 3d6df4e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-<%= render :partial => "diary_entry", :object => diary_index_entry %>
index 4c4fd01e9f0efa03003b877932e9e1fd9e78e3d0..10028bdea2b6c3643028282c0d37bf2c127cf681 100644 (file)
@@ -12,7 +12,7 @@
   <% cl = cycle("table0", "table1") %>
   <tr class="<%= cl %>">
     <td width="25%"><%= link_to comment.diary_entry.title, diary_entry_path(comment.diary_entry.user, comment.diary_entry) %></td>
-    <td width="25%"><span title="<%= l comment.created_at, :format => :friendly %>"><%= t ".ago", :ago => time_ago_in_words(comment.created_at) %></span></td>
+    <td width="25%"><span title="<%= l comment.created_at, :format => :friendly %>"><%= time_ago_in_words(comment.created_at, :scope => :'datetime.distance_in_words_ago') %></span></td>
     <td width="50%" class="richtext"><%= comment.body.to_html %></td>
   </tr>
   <% end -%>
index 4610e5fd7403bdc45ce3598949fb9d9a958e8a75..acf9ac17c7f558a443bd0bde51f58227ead71372 100644 (file)
 <% else %>
   <h4><%= t ".recent_entries" %></h4>
 
-  <% if @user %>
-    <%= render :partial => "diary_entry", :collection => @entries %>
-  <% else %>
-    <%= render :partial => "diary_index_entry", :collection => @entries %>
-  <% end %>
+  <%= render @entries %>
 
   <div class="pagination">
     <% if @entries.size < @page_size -%>
index cc761b15d3b03829997cd75a92d14a8238d804ae..1cc1e1c5363212c303fd8eb6aefdb4c51d1f0b92 100644 (file)
@@ -6,7 +6,7 @@
   </div>
 <% end %>
 
-<%= render :partial => "diary_entry", :object => @entry %>
+<%= render @entry %>
 
 <a id="comments"></a>
 <div class='comments'>
index 87d3b03d016728eaa5c9718baccab46d4bbd8ddd..1c45f41246395d9eb97d4598fef1df7db910ee1b 100644 (file)
         <td>
           <% if issue.user_updated %>
             <%= t ".last_updated_time_user_html", :user => link_to(issue.user_updated.display_name, user_path(issue.user_updated)),
-                                                  :time => distance_of_time_in_words_to_now(issue.updated_at),
+                                                  :time => time_ago_in_words(issue.updated_at, :scope => :'datetime.distance_in_words_ago'),
                                                   :title => l(issue.updated_at) %>
           <% else %>
-            <%= t ".last_updated_time_html", :time => distance_of_time_in_words_to_now(issue.updated_at),
+            <%= t ".last_updated_time_html", :time => time_ago_in_words(issue.updated_at, :scope => :'datetime.distance_in_words_ago'),
                                              :title => l(issue.updated_at) %>
           <% end %>
         </td>
index 2751e1559a4572440f3ab56e60cd88c2da36fe64..c7015578b24ed575ba913cfad7cd4567f990c755 100644 (file)
@@ -26,8 +26,8 @@
     <td><%= link_to note.id, browse_note_path(note) %></td>
     <td><%= note_author(note.author) %></td>
     <td><%= note.comments.first.body.to_html %></td>
-    <td><%= t ".ago_html", :when => friendly_date(note.created_at) %></td>
-    <td><%= t ".ago_html", :when => friendly_date(note.updated_at) %></td>
+    <td><%= friendly_date_ago(note.created_at) %></td>
+    <td><%= friendly_date_ago(note.updated_at) %></td>
   </tr>
 <% end -%>
 </table>
diff --git a/app/views/redactions/_redactions.html.erb b/app/views/redactions/_redactions.html.erb
deleted file mode 100644 (file)
index 225e256..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<ul id="redaction_list">
-  <%= render :partial => "redaction", :collection => @redactions %>
-</ul>
index e3388fafa006b97ce74e1916d37f877ef5b89531..b6b6ef46e063e8f358eac3c64dc6ad8a440a918f 100644 (file)
@@ -4,7 +4,9 @@
 <% end %>
 
 <% unless @redactions.empty? %>
-  <%= render :partial => "redactions" %>
+  <ul id="redaction_list">
+    <%= render @redactions %>
+  </ul>
 <% else %>
   <p><%= t ".empty" %></p>
 <% end %>
index 34f6615002eb454ddafce55e4a68c3fb6bfd91e1..ceeb4d88d709538a86eb0038de2715ca5bcfe262 100644 (file)
@@ -14,7 +14,7 @@
       <% if trace.inserted %>
         (<%= t ".count_points", :count => trace.size.to_s.gsub(/(\d)(?=(\d{3})+$)/, '\1,') %>)
       <% end %>
-      ... <%= t ".ago", :time_in_words_ago => time_ago_in_words(trace.timestamp) %></span>
+      ... <%= time_ago_in_words(trace.timestamp, :scope => :'datetime.distance_in_words_ago') %></span>
       <%= link_to_if trace.inserted?, t(".map"), { :controller => "site", :action => "index", :mlat => trace.latitude, :mlon => trace.longitude, :anchor => "map=14/#{trace.latitude}/#{trace.longitude}" }, { :title => t(".view_map") } %> /
       <%= link_to t(".edit"), { :controller => "site", :action => "edit", :gpx => trace.id }, { :title => t(".edit_map") } %>
       <span class="trace_<%= trace.visibility %>"><%= t("." + trace.visibility) %></span>
index 9db246bd45149cd67180ccfdcf4de801ca023a9a..da40f5a4d64a16133f15b6083f9711c886ecc7a2 100644 (file)
@@ -33,7 +33,7 @@
       </tr>
     </thead>
     <tbody>
-      <%= render :partial => "trace", :collection => @traces unless @traces.nil? %>
+      <%= render @traces unless @traces.nil? %>
     </tbody>
   </table>
 
index 44da21d85b303f8bf968712888f704440637afed..9bd7df5aed930cfdd81825fc1002aa494e44e785 100644 (file)
@@ -28,6 +28,6 @@
 
 <% else %>
 <p>
-  <%= t(".past", :time => distance_of_time_in_words_to_now(@user_block.ends_at)) %>
+  <%= t(".past", :time => time_ago_in_words(@user_block.ends_at, :scope => :'datetime.distance_in_words_ago')) %>
 </p>
 <% end %>
index 28e467fb4ebc84b376b53da39f6f4e7332f77701..7b34d204a96c3edbb5a0ab2b55944be7d647aaa6 100644 (file)
@@ -28,7 +28,7 @@
 </p>
 <% end %>
 
-<p><b><%= t ".created" %></b>: <%= raw t ".ago", :time => friendly_date(@user_block.created_at) %></p>
+<p><b><%= t ".created" %></b>: <%= friendly_date_ago(@user_block.created_at) %></p>
 
 <p><b><%= t ".status" %></b>: <%= block_status(@user_block) %></p>
 
index 9950da0f8f7600479590bc325ef1ae914cc00611..1479a1e4fbbd652e4f64021efed01a1f1bf963b4 100644 (file)
@@ -21,7 +21,7 @@
     <p>
       <% changeset = contact.changesets.first %>
       <% if changeset %>
-        <%= t("users.show.latest edit", :ago => t("users.show.ago", :time_in_words_ago => time_ago_in_words(changeset.created_at))) %>
+        <%= t("users.show.latest edit", :ago => time_ago_in_words(changeset.created_at, :scope => :'datetime.distance_in_words_ago')) %>
         <% comment = changeset.tags["comment"].to_s != "" ? changeset.tags["comment"] : t("browse.no_comment") %>
         "<%= link_to(comment,
                      { :controller => "browse", :action => "changeset", :id => changeset.id },
index ffaceeff012d8a00c0fa6313094451ca2a8b8b1a..f1ef5b5380f4460e84b31676b97a3b444c740bf6 100644 (file)
@@ -30,7 +30,7 @@
           <%= check_box_tag "user_all", "1", false %>
         </td>
       </tr>
-      <%= render :partial => "user", :collection => @users %>
+      <%= render @users %>
     </table>
 
     <div id="user_list_actions buttons">
index 0281703ab73178bcf4583dabd4bafdeece119600..1de83f9d66c0fd0446ef1c1c80362b7d5c3000cf 100644 (file)
@@ -163,14 +163,14 @@ en:
   api:
     notes:
       comment:
-        opened_at_html: "Created %{when} ago"
-        opened_at_by_html: "Created %{when} ago by %{user}"
-        commented_at_html: "Updated %{when} ago"
-        commented_at_by_html: "Updated %{when} ago by %{user}"
-        closed_at_html: "Resolved %{when} ago"
-        closed_at_by_html: "Resolved %{when} ago by %{user}"
-        reopened_at_html: "Reactivated %{when} ago"
-        reopened_at_by_html: "Reactivated %{when} ago by %{user}"
+        opened_at_html: "Created %{when}"
+        opened_at_by_html: "Created %{when} by %{user}"
+        commented_at_html: "Updated %{when}"
+        commented_at_by_html: "Updated %{when}by %{user}"
+        closed_at_html: "Resolved %{when}"
+        closed_at_by_html: "Resolved %{when} by %{user}"
+        reopened_at_html: "Reactivated %{when}"
+        reopened_at_by_html: "Reactivated %{when} by %{user}"
       rss:
         title: "OpenStreetMap Notes"
         description_area: "A list of notes, reported, commented on or closed in your area [(%{min_lat}|%{min_lon}) -- (%{max_lat}|%{max_lon})]"
@@ -185,12 +185,12 @@ en:
   browse:
     created: "Created"
     closed: "Closed"
-    created_html: "Created <abbr title='%{title}'>%{time} ago</abbr>"
-    closed_html: "Closed <abbr title='%{title}'>%{time} ago</abbr>"
-    created_by_html: "Created <abbr title='%{title}'>%{time} ago</abbr> by %{user}"
-    deleted_by_html: "Deleted <abbr title='%{title}'>%{time} ago</abbr> by %{user}"
-    edited_by_html: "Edited <abbr title='%{title}'>%{time} ago</abbr> by %{user}"
-    closed_by_html: "Closed <abbr title='%{title}'>%{time} ago</abbr> by %{user}"
+    created_html: "Created <abbr title='%{title}'>%{time}</abbr>"
+    closed_html: "Closed <abbr title='%{title}'>%{time}</abbr>"
+    created_by_html: "Created <abbr title='%{title}'>%{time}</abbr> by %{user}"
+    deleted_by_html: "Deleted <abbr title='%{title}'>%{time}</abbr> by %{user}"
+    edited_by_html: "Edited <abbr title='%{title}'>%{time}</abbr> by %{user}"
+    closed_by_html: "Closed <abbr title='%{title}'>%{time}</abbr> by %{user}"
     version: "Version"
     in_changeset: "Changeset"
     anonymous: "anonymous"
@@ -210,8 +210,8 @@ en:
       relation: "Relations (%{count})"
       relation_paginated: "Relations (%{x}-%{y} of %{count})"
       comment: "Comments (%{count})"
-      hidden_commented_by: "Hidden comment from %{user} <abbr title='%{exact_time}'>%{when} ago</abbr>"
-      commented_by: "Comment from %{user} <abbr title='%{exact_time}'>%{when} ago</abbr>"
+      hidden_commented_by: "Hidden comment from %{user} <abbr title='%{exact_time}'>%{when}</abbr>"
+      commented_by: "Comment from %{user} <abbr title='%{exact_time}'>%{when}</abbr>"
       changesetxml: "Changeset XML"
       osmchangexml: "osmChange XML"
       feed:
@@ -286,15 +286,15 @@ en:
       open_title: "Unresolved note #%{note_name}"
       closed_title: "Resolved note #%{note_name}"
       hidden_title: "Hidden note #%{note_name}"
-      open_by: "Created by %{user} <abbr title='%{exact_time}'>%{when} ago</abbr>"
-      open_by_anonymous: "Created by anonymous <abbr title='%{exact_time}'>%{when} ago</abbr>"
-      commented_by: "Comment from %{user} <abbr title='%{exact_time}'>%{when} ago</abbr>"
-      commented_by_anonymous: "Comment from anonymous <abbr title='%{exact_time}'>%{when} ago</abbr>"
-      closed_by: "Resolved by %{user} <abbr title='%{exact_time}'>%{when} ago</abbr>"
-      closed_by_anonymous: "Resolved by anonymous <abbr title='%{exact_time}'>%{when} ago</abbr>"
-      reopened_by: "Reactivated by %{user} <abbr title='%{exact_time}'>%{when} ago</abbr>"
-      reopened_by_anonymous: "Reactivated by anonymous <abbr title='%{exact_time}'>%{when} ago</abbr>"
-      hidden_by: "Hidden by %{user} <abbr title='%{exact_time}'>%{when} ago</abbr>"
+      open_by: "Created by %{user} <abbr title='%{exact_time}'>%{when}</abbr>"
+      open_by_anonymous: "Created by anonymous <abbr title='%{exact_time}'>%{when}</abbr>"
+      commented_by: "Comment from %{user} <abbr title='%{exact_time}'>%{when}</abbr>"
+      commented_by_anonymous: "Comment from anonymous <abbr title='%{exact_time}'>%{when}</abbr>"
+      closed_by: "Resolved by %{user} <abbr title='%{exact_time}'>%{when}</abbr>"
+      closed_by_anonymous: "Resolved by anonymous <abbr title='%{exact_time}'>%{when}</abbr>"
+      reopened_by: "Reactivated by %{user} <abbr title='%{exact_time}'>%{when}</abbr>"
+      reopened_by_anonymous: "Reactivated by anonymous <abbr title='%{exact_time}'>%{when}</abbr>"
+      hidden_by: "Hidden by %{user} <abbr title='%{exact_time}'>%{when}</abbr>"
       report: Report this note
     query:
       title: "Query Features"
@@ -333,7 +333,7 @@ en:
   changeset_comments:
     comment:
       comment: "New comment on changeset #%{changeset_id} by %{author}"
-      commented_at_by_html: "Updated %{when} ago by %{user}"
+      commented_at_by_html: "Updated %{when} by %{user}"
     comments:
       comment: "New comment on changeset #%{changeset_id} by %{author}"
     index:
@@ -415,7 +415,6 @@ en:
       post: Post
       when: When
       comment: Comment
-      ago: "%{ago} ago"
       newer_comments: "Newer Comments"
       older_comments: "Older Comments"
   geocoder:
@@ -1028,8 +1027,8 @@ en:
       status: Status
       reports: Reports
       last_updated: Last Updated
-      last_updated_time_html: "<abbr title='%{title}'>%{time} ago</abbr>"
-      last_updated_time_user_html: "<abbr title='%{title}'>%{time} ago</abbr> by %{user}"
+      last_updated_time_html: "<abbr title='%{title}'>%{time}</abbr>"
+      last_updated_time_user_html: "<abbr title='%{title}'>%{time}</abbr> by %{user}"
       link_to_reports: View Reports
       reported_user: Reported User
       reports_count:
@@ -1857,7 +1856,6 @@ en:
     trace:
       pending: "PENDING"
       count_points: "%{count} points"
-      ago: "%{time_in_words_ago} ago"
       more: "more"
       trace_details: "View Trace Details"
       view_map: "View Map"
@@ -2130,12 +2128,10 @@ en:
       remove as friend: Unfriend
       add as friend: Add Friend
       mapper since: "Mapper since:"
-      ago: "(%{time_in_words_ago} ago)"
       ct status: "Contributor terms:"
       ct undecided: Undecided
       ct declined: Declined
-      ct accepted: Accepted %{ago} ago
-      latest edit: "Latest edit %{ago}:"
+      latest edit: "Latest edit (%{ago}):"
       email address: "Email address:"
       created from: "Created from:"
       status: "Status:"
@@ -2368,7 +2364,7 @@ en:
       title: "Revoking block on %{block_on}"
       heading: "Revoking block on %{block_on} by %{block_by}"
       time_future: "This block will end in %{time}."
-      past: "This block ended %{time} ago and cannot be revoked now."
+      past: "This block ended %{time} and cannot be revoked now."
       confirm: "Are you sure you wish to revoke this block?"
       revoke: "Revoke!"
       flash: "This block has been revoked."
@@ -2376,7 +2372,7 @@ en:
       time_future: "Ends in %{time}."
       until_login: "Active until the user logs in."
       time_future_and_until_login: "Ends in %{time} and after the user has logged in."
-      time_past: "Ended %{time} ago."
+      time_past: "Ended %{time}."
       block_duration:
         hours:
           one: "1 hour"
@@ -2404,10 +2400,7 @@ en:
     show:
       title: "%{block_on} blocked by %{block_by}"
       heading: "%{block_on} blocked by %{block_by}"
-      time_future: "Ends in %{time}"
-      time_past: "Ended %{time} ago"
       created: "Created"
-      ago: "%{time} ago"
       status: "Status"
       show: "Show"
       edit: "Edit"
@@ -2441,7 +2434,6 @@ en:
       description: "Description"
       created_at: "Created at"
       last_changed: "Last changed"
-      ago_html: "%{when} ago"
   javascripts:
     close: Close
     share:
index 499fefbd7e2ee507dc708877350c3a6dd81f5580..820829aadc6f21a79e230bd3207867834262a53e 100644 (file)
@@ -250,27 +250,27 @@ module Api
       anon_trace_file = create(:trace, :visibility => "private")
 
       # First with no auth
-      put :update, :params => { :id => public_trace_file.id }, :body => public_trace_file.to_xml.to_s
+      put :update, :params => { :id => public_trace_file.id }, :body => create_trace_xml(public_trace_file)
       assert_response :unauthorized
 
       # Now with some other user, which should fail
       basic_authorization create(:user).display_name, "test"
-      put :update, :params => { :id => public_trace_file.id }, :body => public_trace_file.to_xml.to_s
+      put :update, :params => { :id => public_trace_file.id }, :body => create_trace_xml(public_trace_file)
       assert_response :forbidden
 
       # Now with a trace which doesn't exist
       basic_authorization create(:user).display_name, "test"
-      put :update, :params => { :id => 0 }, :body => public_trace_file.to_xml.to_s
+      put :update, :params => { :id => 0 }, :body => create_trace_xml(public_trace_file)
       assert_response :not_found
 
       # Now with a trace which did exist but has been deleted
       basic_authorization deleted_trace_file.user.display_name, "test"
-      put :update, :params => { :id => deleted_trace_file.id }, :body => deleted_trace_file.to_xml.to_s
+      put :update, :params => { :id => deleted_trace_file.id }, :body => create_trace_xml(deleted_trace_file)
       assert_response :not_found
 
       # Now try an update with the wrong ID
       basic_authorization public_trace_file.user.display_name, "test"
-      put :update, :params => { :id => public_trace_file.id }, :body => anon_trace_file.to_xml.to_s
+      put :update, :params => { :id => public_trace_file.id }, :body => create_trace_xml(anon_trace_file)
       assert_response :bad_request,
                       "should not be able to update a trace with a different ID from the XML"
 
@@ -279,7 +279,7 @@ module Api
       t = public_trace_file
       t.description = "Changed description"
       t.visibility = "private"
-      put :update, :params => { :id => t.id }, :body => t.to_xml.to_s
+      put :update, :params => { :id => t.id }, :body => create_trace_xml(t)
       assert_response :success
       nt = Trace.find(t.id)
       assert_equal nt.description, t.description
@@ -292,7 +292,7 @@ module Api
       trace = tracetag.trace
       basic_authorization trace.user.display_name, "test"
 
-      put :update, :params => { :id => trace.id }, :body => trace.to_xml.to_s
+      put :update, :params => { :id => trace.id }, :body => create_trace_xml(trace)
       assert_response :success
 
       updated = Trace.find(trace.id)
@@ -339,5 +339,27 @@ module Api
       assert_equal content_type, response.content_type
       assert_equal "attachment; filename=\"#{trace.id}.#{extension}\"", @response.header["Content-Disposition"]
     end
+
+    ##
+    # build XML for traces
+    # this builds a minimum viable XML for the tests in this suite
+    def create_trace_xml(trace)
+      root = XML::Document.new
+      root.root = XML::Node.new "osm"
+      trc = XML::Node.new "gpx_file"
+      trc["id"] = trace.id.to_s
+      trc["visibility"] = trace.visibility
+      trc["visible"] = trace.visible.to_s
+      desc = XML::Node.new "description"
+      desc << trace.description
+      trc << desc
+      trace.tags.each do |tag|
+        t = XML::Node.new "tag"
+        t << tag.tag
+        trc << t
+      end
+      root.root << trc
+      root.to_s
+    end
   end
 end
index 408236879c49ea6c49b7b16445afb53af928ede7..ce82f3ab5b9df6c9daabe78a28e656cae17a2408 100644 (file)
@@ -8,8 +8,8 @@ class NoteHelperTest < ActionView::TestCase
     date = Time.new(2014, 3, 5, 21, 37, 45, "+00:00")
     user = create(:user)
 
-    assert_match %r{^Created by anonymous <abbr title='Wed, 05 Mar 2014 21:37:45 \+0000'><span title=" 5 March 2014 at 21:37">.*</span> ago</abbr>$}, note_event("open", date, nil)
-    assert_match %r{^Resolved by <a href="/user/#{ERB::Util.u(user.display_name)}">#{user.display_name}</a> <abbr title='Wed, 05 Mar 2014 21:37:45 \+0000'><span title=" 5 March 2014 at 21:37">.*</span> ago</abbr>$}, note_event("closed", date, user)
+    assert_match %r{^Created by anonymous <abbr title='Wed, 05 Mar 2014 21:37:45 \+0000'><span title=" 5 March 2014 at 21:37">.* ago</span></abbr>$}, note_event("open", date, nil)
+    assert_match %r{^Resolved by <a href="/user/#{ERB::Util.u(user.display_name)}">#{user.display_name}</a> <abbr title='Wed, 05 Mar 2014 21:37:45 \+0000'><span title=" 5 March 2014 at 21:37">.* ago</span></abbr>$}, note_event("closed", date, user)
   end
 
   def test_note_author
index 058d6abd40aca00e32f4ecf95f3f916ef3d64884..26c303cfa8fd24e8b48a82acb848fa33ffb452bc 100644 (file)
@@ -10,7 +10,13 @@ class UserRolesHelperTest < ActionView::TestCase
     assert_dom_equal "", icon
 
     icon = role_icon(create(:moderator_user), "moderator")
-    assert_dom_equal '<picture><source srcset="/images/roles/moderator.svg" type="image/svg+xml" /><img srcset="/images/roles/moderator.svg" border="0" alt="This user is a moderator" title="This user is a moderator" src="/images/roles/moderator.png" width="20" height="20" /></picture>', icon
+    expected = <<~HTML.delete("\n")
+      <picture>
+      <source srcset="/images/roles/moderator.svg" type="image/svg+xml" />
+      <img srcset="/images/roles/moderator.svg" border="0" alt="This user is a moderator" title="This user is a moderator" src="/images/roles/moderator.png" width="20" height="20" />
+      </picture>
+    HTML
+    assert_dom_equal expected, icon
   end
 
   def test_role_icon_administrator
@@ -18,11 +24,27 @@ class UserRolesHelperTest < ActionView::TestCase
 
     user = create(:user)
     icon = role_icon(user, "moderator")
-    assert_dom_equal %(<a confirm="Are you sure you want to grant the role `moderator&#39; to the user `#{user.display_name}&#39;?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(user.display_name)}/role/moderator/grant"><picture><source srcset="/images/roles/blank_moderator.svg" type="image/svg+xml" /><img srcset="/images/roles/blank_moderator.svg" border="0" alt="Grant moderator access" title="Grant moderator access" src="/images/roles/blank_moderator.png" width="20" height="20" /></picture></a>), icon
+    expected = <<~HTML.delete("\n")
+      <a confirm="Are you sure you want to grant the role `moderator&#39; to the user `#{user.display_name}&#39;?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(user.display_name)}/role/moderator/grant">
+      <picture>
+      <source srcset="/images/roles/blank_moderator.svg" type="image/svg+xml" />
+      <img srcset="/images/roles/blank_moderator.svg" border="0" alt="Grant moderator access" title="Grant moderator access" src="/images/roles/blank_moderator.png" width="20" height="20" />
+      </picture>
+      </a>
+    HTML
+    assert_dom_equal expected, icon
 
     moderator_user = create(:moderator_user)
     icon = role_icon(moderator_user, "moderator")
-    assert_dom_equal %(<a confirm="Are you sure you want to revoke the role `moderator&#39; from the user `#{moderator_user.display_name}&#39;?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(moderator_user.display_name)}/role/moderator/revoke"><picture><source srcset="/images/roles/moderator.svg" type="image/svg+xml" /><img srcset="/images/roles/moderator.svg" border="0" alt="Revoke moderator access" title="Revoke moderator access" src="/images/roles/moderator.png" width="20" height="20" /></picture></a>), icon
+    expected = <<~HTML.delete("\n")
+      <a confirm="Are you sure you want to revoke the role `moderator&#39; from the user `#{moderator_user.display_name}&#39;?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(moderator_user.display_name)}/role/moderator/revoke">
+      <picture>
+      <source srcset="/images/roles/moderator.svg" type="image/svg+xml" />
+      <img srcset="/images/roles/moderator.svg" border="0" alt="Revoke moderator access" title="Revoke moderator access" src="/images/roles/moderator.png" width="20" height="20" />
+      </picture>
+      </a>
+    HTML
+    assert_dom_equal expected, icon
   end
 
   def test_role_icons_normal
@@ -32,10 +54,26 @@ class UserRolesHelperTest < ActionView::TestCase
     assert_dom_equal "  ", icons
 
     icons = role_icons(create(:moderator_user))
-    assert_dom_equal '  <picture><source srcset="/images/roles/moderator.svg" type="image/svg+xml" /><img srcset="/images/roles/moderator.svg" border="0" alt="This user is a moderator" title="This user is a moderator" src="/images/roles/moderator.png" width="20" height="20" /></picture>', icons
+    expected = "  " + <<~HTML.delete("\n")
+      <picture>
+      <source srcset="/images/roles/moderator.svg" type="image/svg+xml" />
+      <img srcset="/images/roles/moderator.svg" border="0" alt="This user is a moderator" title="This user is a moderator" src="/images/roles/moderator.png" width="20" height="20" />
+      </picture>
+    HTML
+    assert_dom_equal expected, icons
 
     icons = role_icons(create(:super_user))
-    assert_dom_equal ' <picture><source srcset="/images/roles/administrator.svg" type="image/svg+xml" /><img srcset="/images/roles/administrator.svg" border="0" alt="This user is an administrator" title="This user is an administrator" src="/images/roles/administrator.png" width="20" height="20" /></picture> <picture><source srcset="/images/roles/moderator.svg" type="image/svg+xml" /><img srcset="/images/roles/moderator.svg" border="0" alt="This user is a moderator" title="This user is a moderator" src="/images/roles/moderator.png" width="20" height="20" /></picture>', icons
+    expected = " " + <<~HTML.delete("\n")
+      <picture>
+      <source srcset="/images/roles/administrator.svg" type="image/svg+xml" />
+      <img srcset="/images/roles/administrator.svg" border="0" alt="This user is an administrator" title="This user is an administrator" src="/images/roles/administrator.png" width="20" height="20" />
+      </picture>
+       <picture>
+      <source srcset="/images/roles/moderator.svg" type="image/svg+xml" />
+      <img srcset="/images/roles/moderator.svg" border="0" alt="This user is a moderator" title="This user is a moderator" src="/images/roles/moderator.png" width="20" height="20" />
+      </picture>
+    HTML
+    assert_dom_equal expected, icons
   end
 
   def test_role_icons_administrator
@@ -43,14 +81,56 @@ class UserRolesHelperTest < ActionView::TestCase
 
     user = create(:user)
     icons = role_icons(user)
-    assert_dom_equal %( <a confirm="Are you sure you want to grant the role `administrator&#39; to the user `#{user.display_name}&#39;?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(user.display_name)}/role/administrator/grant"><picture><source srcset="/images/roles/blank_administrator.svg" type="image/svg+xml" /><img srcset="/images/roles/blank_administrator.svg" border="0" alt="Grant administrator access" title="Grant administrator access" src="/images/roles/blank_administrator.png" width="20" height="20" /></picture></a> <a confirm="Are you sure you want to grant the role `moderator&#39; to the user `#{user.display_name}&#39;?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(user.display_name)}/role/moderator/grant"><picture><source srcset="/images/roles/blank_moderator.svg" type="image/svg+xml" /><img srcset="/images/roles/blank_moderator.svg" border="0" alt="Grant moderator access" title="Grant moderator access" src="/images/roles/blank_moderator.png" width="20" height="20" /></picture></a>), icons
+    expected = " " + <<~HTML.delete("\n")
+      <a confirm="Are you sure you want to grant the role `administrator&#39; to the user `#{user.display_name}&#39;?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(user.display_name)}/role/administrator/grant">
+      <picture>
+      <source srcset="/images/roles/blank_administrator.svg" type="image/svg+xml" />
+      <img srcset="/images/roles/blank_administrator.svg" border="0" alt="Grant administrator access" title="Grant administrator access" src="/images/roles/blank_administrator.png" width="20" height="20" />
+      </picture>
+      </a>
+       <a confirm="Are you sure you want to grant the role `moderator&#39; to the user `#{user.display_name}&#39;?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(user.display_name)}/role/moderator/grant">
+      <picture>
+      <source srcset="/images/roles/blank_moderator.svg" type="image/svg+xml" />
+      <img srcset="/images/roles/blank_moderator.svg" border="0" alt="Grant moderator access" title="Grant moderator access" src="/images/roles/blank_moderator.png" width="20" height="20" />
+      </picture>
+      </a>
+    HTML
+    assert_dom_equal expected, icons
 
     moderator_user = create(:moderator_user)
     icons = role_icons(moderator_user)
-    assert_dom_equal %( <a confirm="Are you sure you want to grant the role `administrator&#39; to the user `#{moderator_user.display_name}&#39;?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(moderator_user.display_name)}/role/administrator/grant"><picture><source srcset="/images/roles/blank_administrator.svg" type="image/svg+xml" /><img srcset="/images/roles/blank_administrator.svg" border="0" alt="Grant administrator access" title="Grant administrator access" src="/images/roles/blank_administrator.png" width="20" height="20" /></picture></a> <a confirm="Are you sure you want to revoke the role `moderator&#39; from the user `#{moderator_user.display_name}&#39;?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(moderator_user.display_name)}/role/moderator/revoke"><picture><source srcset="/images/roles/moderator.svg" type="image/svg+xml" /><img srcset="/images/roles/moderator.svg" border="0" alt="Revoke moderator access" title="Revoke moderator access" src="/images/roles/moderator.png" width="20" height="20" /></picture></a>), icons
+    expected = " " + <<~HTML.delete("\n")
+      <a confirm="Are you sure you want to grant the role `administrator&#39; to the user `#{moderator_user.display_name}&#39;?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(moderator_user.display_name)}/role/administrator/grant">
+      <picture>
+      <source srcset="/images/roles/blank_administrator.svg" type="image/svg+xml" />
+      <img srcset="/images/roles/blank_administrator.svg" border="0" alt="Grant administrator access" title="Grant administrator access" src="/images/roles/blank_administrator.png" width="20" height="20" />
+      </picture>
+      </a>
+       <a confirm="Are you sure you want to revoke the role `moderator&#39; from the user `#{moderator_user.display_name}&#39;?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(moderator_user.display_name)}/role/moderator/revoke">
+      <picture>
+      <source srcset="/images/roles/moderator.svg" type="image/svg+xml" />
+      <img srcset="/images/roles/moderator.svg" border="0" alt="Revoke moderator access" title="Revoke moderator access" src="/images/roles/moderator.png" width="20" height="20" />
+      </picture>
+      </a>
+    HTML
+    assert_dom_equal expected, icons
 
     super_user = create(:super_user)
     icons = role_icons(super_user)
-    assert_dom_equal %( <a confirm="Are you sure you want to revoke the role `administrator&#39; from the user `#{super_user.display_name}&#39;?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(super_user.display_name)}/role/administrator/revoke"><picture><source srcset="/images/roles/administrator.svg" type="image/svg+xml" /><img srcset="/images/roles/administrator.svg" border="0" alt="Revoke administrator access" title="Revoke administrator access" src="/images/roles/administrator.png" width="20" height="20" /></picture></a> <a confirm="Are you sure you want to revoke the role `moderator&#39; from the user `#{super_user.display_name}&#39;?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(super_user.display_name)}/role/moderator/revoke"><picture><source srcset="/images/roles/moderator.svg" type="image/svg+xml" /><img srcset="/images/roles/moderator.svg" border="0" alt="Revoke moderator access" title="Revoke moderator access" src="/images/roles/moderator.png" width="20" height="20" /></picture></a>), icons
+    expected = " " + <<~HTML.delete("\n")
+      <a confirm="Are you sure you want to revoke the role `administrator&#39; from the user `#{super_user.display_name}&#39;?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(super_user.display_name)}/role/administrator/revoke">
+      <picture>
+      <source srcset="/images/roles/administrator.svg" type="image/svg+xml" />
+      <img srcset="/images/roles/administrator.svg" border="0" alt="Revoke administrator access" title="Revoke administrator access" src="/images/roles/administrator.png" width="20" height="20" />
+      </picture>
+      </a>
+       <a confirm="Are you sure you want to revoke the role `moderator&#39; from the user `#{super_user.display_name}&#39;?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(super_user.display_name)}/role/moderator/revoke">
+      <picture>
+      <source srcset="/images/roles/moderator.svg" type="image/svg+xml" />
+      <img srcset="/images/roles/moderator.svg" border="0" alt="Revoke moderator access" title="Revoke moderator access" src="/images/roles/moderator.png" width="20" height="20" />
+      </picture>
+      </a>
+    HTML
+    assert_dom_equal expected, icons
   end
 end