]> git.openstreetmap.org Git - rails.git/commitdiff
Fix handling of title when replying to diary entries
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 11 Apr 2018 06:03:17 +0000 (14:03 +0800)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 11 Apr 2018 06:03:17 +0000 (14:03 +0800)
app/views/diary_entry/_diary_entry.html.erb
app/views/message/new.html.erb
config/routes.rb
test/system/diary_entry_test.rb [new file with mode: 0644]
test/test_helper.rb

index 763915e46cb15937a62e8e737b9a0ec722824430..e4b2c214391d1ea02b221d42828a68ee50a83b92 100644 (file)
@@ -23,7 +23,7 @@
   <ul class='secondary-actions clearfix'>
     <% if params[:action] == 'list' %>
       <li><%= link_to t('diary_entry.diary_entry.comment_link'), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id, :anchor => 'newcomment' %></li>
-      <li><%= link_to t('diary_entry.diary_entry.reply_link'), :controller => 'message', :action => 'new', :display_name => diary_entry.user.display_name, :title => "Re: #{diary_entry.title}" %></li>
+      <li><%= link_to t('diary_entry.diary_entry.reply_link'), :controller => 'message', :action => 'new', :display_name => diary_entry.user.display_name, :message => { :title => "Re: #{diary_entry.title}" } %></li>
       <li><%= link_to t('diary_entry.diary_entry.comment_count', :count => diary_entry.visible_comments.count), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id, :anchor => 'comments' %></li>
     <% end %>
 
index 0b54adb1caecb87944ab19c5d940a86e8bbcff88..03454767a6c0eff7414d2bfccffa333b3d8b5131 100644 (file)
@@ -7,11 +7,11 @@
 <%= form_for :message, :html => { :class => 'standard-form' }, :url => { :action => "new", :display_name => @message.recipient.display_name } do |f| %>
   <fieldset>
     <div class='form-row'>
-      <label class="standard-label"><%= t'message.new.subject' %></label>
+      <label class="standard-label" for="message_title"><%= t'message.new.subject' %></label>
       <%= f.text_field :title, :size => 60, :class => "richtext_title" %>
     </div>
     <div class='form-row'>
-      <label class="standard-label"><%= t'message.new.body' %></label>
+      <label class="standard-label" for="message_body"><%= t'message.new.body' %></label>
       <%= richtext_area :message, :body, :cols => 80, :rows => 20 %>
     </div>
     <div class='buttons'>
index 1016a89de4c937fdc27fce2f8d551398e8cfa1fd..ca0c4ecf01713a236a25f1fb834344adaabd2190 100644 (file)
@@ -224,7 +224,7 @@ OpenStreetMap::Application.routes.draw do
   get "/user/:display_name/diary" => "diary_entry#list"
   get "/diary/:language" => "diary_entry#list"
   get "/diary" => "diary_entry#list"
-  get "/user/:display_name/diary/:id" => "diary_entry#view", :id => /\d+/
+  get "/user/:display_name/diary/:id" => "diary_entry#view", :id => /\d+/, :as => :diary_entry
   post "/user/:display_name/diary/:id/newcomment" => "diary_entry#comment", :id => /\d+/
   match "/user/:display_name/diary/:id/edit" => "diary_entry#edit", :via => [:get, :post], :id => /\d+/
   post "/user/:display_name/diary/:id/hide" => "diary_entry#hide", :id => /\d+/, :as => :hide_diary_entry
diff --git a/test/system/diary_entry_test.rb b/test/system/diary_entry_test.rb
new file mode 100644 (file)
index 0000000..b8eb5f6
--- /dev/null
@@ -0,0 +1,18 @@
+require "application_system_test_case"
+
+class DiaryEntryTest < ApplicationSystemTestCase
+  def setup
+    create(:language, :code => "en")
+    @diary_entry = create(:diary_entry)
+  end
+
+  test "reply to diary entry should prefill the message subject" do
+    sign_in_as(create(:user))
+    visit diary_path
+
+    click_on "Reply to this entry"
+
+    assert page.has_content? "Send a new message"
+    assert_equal "Re: #{@diary_entry.title}", page.find_field("Subject").value
+  end
+end
index 385a2f6825d0d9ea27baae625791d3b6a55e5067..7198519a75f4829c88e36da2add6de413a2aa6f0 100644 (file)
@@ -150,5 +150,13 @@ module ActiveSupport
         end
       end
     end
+
+    def sign_in_as(user)
+      stub_hostip_requests
+      visit login_path
+      fill_in "username", :with => user.email
+      fill_in "password", :with => "test"
+      click_on "Login", :match => :first
+    end
   end
 end