]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/2237'
authorTom Hughes <tom@compton.nu>
Thu, 30 May 2019 08:20:37 +0000 (09:20 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 30 May 2019 08:20:37 +0000 (09:20 +0100)
54 files changed:
.rubocop_todo.yml
app/abilities/ability.rb
app/controllers/diary_entries_controller.rb
app/models/acl.rb
app/models/changeset.rb
app/models/changeset_comment.rb
app/models/changeset_tag.rb
app/models/diary_comment.rb
app/models/diary_entry.rb
app/models/diary_entry_subscription.rb
app/models/friend.rb
app/models/message.rb
app/models/node.rb
app/models/node_tag.rb
app/models/note.rb
app/models/note_comment.rb
app/models/old_node.rb
app/models/old_node_tag.rb
app/models/old_relation.rb
app/models/old_relation_member.rb
app/models/old_relation_tag.rb
app/models/old_way.rb
app/models/old_way_node.rb
app/models/old_way_tag.rb
app/models/redaction.rb
app/models/relation.rb
app/models/relation_member.rb
app/models/relation_tag.rb
app/models/trace.rb
app/models/tracepoint.rb
app/models/tracetag.rb
app/models/user.rb
app/models/user_block.rb
app/models/user_preference.rb
app/models/user_role.rb
app/models/user_token.rb
app/models/way.rb
app/models/way_node.rb
app/models/way_tag.rb
app/views/diary_entries/_form.html.erb [new file with mode: 0644]
app/views/diary_entries/edit.html.erb
app/views/diary_entries/index.html.erb
app/views/diary_entries/new.html.erb [new file with mode: 0644]
app/views/layouts/_header.html.erb
app/views/site/about.html.erb
app/views/users/show.html.erb
config/locales/en.yml
config/routes.rb
config/settings.yml
config/settings/test.yml
test/controllers/diary_entries_controller_test.rb
test/controllers/users_controller_test.rb
test/integration/user_diaries_test.rb
test/system/diary_entry_test.rb

index f989d393d21b145266974809a700885a9834f15e..d63584223f2dba242dbd7f469aeb63b1306478e0 100644 (file)
@@ -40,7 +40,7 @@ Metrics/AbcSize:
 # Configuration parameters: CountComments, ExcludedMethods.
 # ExcludedMethods: refine
 Metrics/BlockLength:
-  Max: 262
+  Max: 263
 
 # Offense count: 11
 # Configuration parameters: CountBlocks.
index d2864e452ab975c06ba98c4d2b6ac221f67ee693..1106d843e8e141772ffcee162be7c1148611cca9 100644 (file)
@@ -36,7 +36,7 @@ class Ability
 
       if Settings.status != "database_offline"
         can [:index, :new, :create, :show, :edit, :update, :destroy], ClientApplication
-        can [:create, :edit, :comment, :subscribe, :unsubscribe], DiaryEntry
+        can [:new, :create, :edit, :update, :comment, :subscribe, :unsubscribe], DiaryEntry
         can [:new, :create, :reply, :show, :inbox, :outbox, :mark, :destroy], Message
         can [:close, :reopen], Note
         can [:new, :create], Report
index fb1e7b702a6aa92250f24eb914be3633c4ca4cfc..1e113e09f8df406a36473be4b5b281019af044ae 100644 (file)
@@ -8,38 +8,40 @@ class DiaryEntriesController < ApplicationController
   authorize_resource
 
   before_action :lookup_user, :only => [:show, :comments]
-  before_action :check_database_writable, :only => [:new, :edit, :comment, :hide, :hidecomment, :subscribe, :unsubscribe]
-  before_action :allow_thirdparty_images, :only => [:new, :edit, :index, :show, :comments]
+  before_action :check_database_writable, :only => [:new, :create, :edit, :update, :comment, :hide, :hidecomment, :subscribe, :unsubscribe]
+  before_action :allow_thirdparty_images, :only => [:new, :create, :edit, :update, :index, :show, :comments]
 
   def new
     @title = t "diary_entries.new.title"
 
-    if request.post?
-      @diary_entry = DiaryEntry.new(entry_params)
-      @diary_entry.user = current_user
+    default_lang = current_user.preferences.where(:k => "diary.default_language").first
+    lang_code = default_lang ? default_lang.v : current_user.preferred_language
+    @diary_entry = DiaryEntry.new(entry_params.merge(:language_code => lang_code))
+    set_map_location
+    render :action => "new"
+  end
 
-      if @diary_entry.save
-        default_lang = current_user.preferences.where(:k => "diary.default_language").first
-        if default_lang
-          default_lang.v = @diary_entry.language_code
-          default_lang.save!
-        else
-          current_user.preferences.create(:k => "diary.default_language", :v => @diary_entry.language_code)
-        end
+  def create
+    @title = t "diary_entries.new.title"
 
-        # Subscribe user to diary comments
-        @diary_entry.subscriptions.create(:user => current_user)
+    @diary_entry = DiaryEntry.new(entry_params)
+    @diary_entry.user = current_user
 
-        redirect_to :action => "index", :display_name => current_user.display_name
+    if @diary_entry.save
+      default_lang = current_user.preferences.where(:k => "diary.default_language").first
+      if default_lang
+        default_lang.v = @diary_entry.language_code
+        default_lang.save!
       else
-        render :action => "edit"
+        current_user.preferences.create(:k => "diary.default_language", :v => @diary_entry.language_code)
       end
+
+      # Subscribe user to diary comments
+      @diary_entry.subscriptions.create(:user => current_user)
+
+      redirect_to :action => "index", :display_name => current_user.display_name
     else
-      default_lang = current_user.preferences.where(:k => "diary.default_language").first
-      lang_code = default_lang ? default_lang.v : current_user.preferred_language
-      @diary_entry = DiaryEntry.new(entry_params.merge(:language_code => lang_code))
-      set_map_location
-      render :action => "edit"
+      render :action => "new"
     end
   end
 
@@ -47,13 +49,25 @@ class DiaryEntriesController < ApplicationController
     @title = t "diary_entries.edit.title"
     @diary_entry = DiaryEntry.find(params[:id])
 
+    redirect_to diary_entry_path(@diary_entry.user, @diary_entry) if current_user != @diary_entry.user
+
+    set_map_location
+  rescue ActiveRecord::RecordNotFound
+    render :action => "no_such_entry", :status => :not_found
+  end
+
+  def update
+    @title = t "diary_entries.edit.title"
+    @diary_entry = DiaryEntry.find(params[:id])
+
     if current_user != @diary_entry.user
       redirect_to diary_entry_path(@diary_entry.user, @diary_entry)
     elsif params[:diary_entry] && @diary_entry.update(entry_params)
       redirect_to diary_entry_path(@diary_entry.user, @diary_entry)
+    else
+      set_map_location
+      render :action => "edit"
     end
-
-    set_map_location
   rescue ActiveRecord::RecordNotFound
     render :action => "no_such_entry", :status => :not_found
   end
@@ -166,6 +180,10 @@ class DiaryEntriesController < ApplicationController
     else
       @entries = DiaryEntry.joins(:user).where(:users => { :status => %w[active confirmed] })
 
+      # Items can't be flagged as deleted in the RSS format.
+      # For the general feeds, allow a delay before publishing, to help spam fighting
+      @entries = @entries.where("created_at < :time", :time => Settings.diary_feed_delay.hours.ago)
+
       if params[:language]
         @entries = @entries.where(:language_code => params[:language])
         @title = t("diary_entries.feed.language.title", :language_name => Language.find(params[:language]).english_name)
@@ -177,7 +195,6 @@ class DiaryEntriesController < ApplicationController
         @link = url_for :action => "index", :host => Settings.server_url, :protocol => Settings.server_protocol
       end
     end
-
     @entries = @entries.visible.includes(:user).order("created_at DESC").limit(20)
   end
 
index ea19c74b0f0082302ed9b740525377c58bd15b6c..cf83e673c0ecfbcfdf48dd82c73d74104eae7516 100644 (file)
@@ -2,7 +2,7 @@
 #
 # Table name: acls
 #
-#  id      :integer          not null, primary key
+#  id      :bigint(8)        not null, primary key
 #  address :inet
 #  k       :string           not null
 #  v       :string
index b98d213c713015e205c7eaaaa4ab4853278b41ce..d57086a8e040062af55313a99cbb8b8dd477ab60 100644 (file)
@@ -2,8 +2,8 @@
 #
 # Table name: changesets
 #
-#  id          :integer          not null, primary key
-#  user_id     :integer          not null
+#  id          :bigint(8)        not null, primary key
+#  user_id     :bigint(8)        not null
 #  created_at  :datetime         not null
 #  min_lat     :integer
 #  max_lat     :integer
@@ -14,7 +14,7 @@
 #
 # Indexes
 #
-#  changesets_bbox_idx                (min_lat,max_lat,min_lon,max_lon)
+#  changesets_bbox_idx                (min_lat,max_lat,min_lon,max_lon) USING gist
 #  changesets_closed_at_idx           (closed_at)
 #  changesets_created_at_idx          (created_at)
 #  changesets_user_id_created_at_idx  (user_id,created_at)
index a0ad6f2ea4a17dc5f3db58d3d01c1bb4d646886b..529641c7e94ffb968be8fd31e0532e0e4eb97c81 100644 (file)
@@ -3,8 +3,8 @@
 # Table name: changeset_comments
 #
 #  id           :integer          not null, primary key
-#  changeset_id :integer          not null
-#  author_id    :integer          not null
+#  changeset_id :bigint(8)        not null
+#  author_id    :bigint(8)        not null
 #  body         :text             not null
 #  created_at   :datetime         not null
 #  visible      :boolean          not null
index 942fafb2a34d61646d2e38d9f2fd4044d34c81b5..751029e03995c60835dc1d7eb0ab79a21fb48b3e 100644 (file)
@@ -2,7 +2,7 @@
 #
 # Table name: changeset_tags
 #
-#  changeset_id :integer          not null, primary key
+#  changeset_id :bigint(8)        not null, primary key
 #  k            :string           default(""), not null, primary key
 #  v            :string           default(""), not null
 #
index ade7a64ea317fd38d00dc5b5ef6d5318068bc904..4ae21be8881922e49c799ba0868e93ba0f5e77f5 100644 (file)
@@ -2,9 +2,9 @@
 #
 # Table name: diary_comments
 #
-#  id             :integer          not null, primary key
-#  diary_entry_id :integer          not null
-#  user_id        :integer          not null
+#  id             :bigint(8)        not null, primary key
+#  diary_entry_id :bigint(8)        not null
+#  user_id        :bigint(8)        not null
 #  body           :text             not null
 #  created_at     :datetime         not null
 #  updated_at     :datetime         not null
index d6124199352481895af958f7ae5c25b7e8c02c1a..4affe8b597f1269e92839fa201ba9bc683ee93e7 100644 (file)
@@ -2,8 +2,8 @@
 #
 # Table name: diary_entries
 #
-#  id            :integer          not null, primary key
-#  user_id       :integer          not null
+#  id            :bigint(8)        not null, primary key
+#  user_id       :bigint(8)        not null
 #  title         :string           not null
 #  body          :text             not null
 #  created_at    :datetime         not null
index 6d24c4598c42af2eb22c98732c05f605f1d6a166..6e9a103adafac0d1315ecd1e956ff32cfc0abc2e 100644 (file)
@@ -2,8 +2,8 @@
 #
 # Table name: diary_entry_subscriptions
 #
-#  user_id        :integer          not null, primary key
-#  diary_entry_id :integer          not null, primary key
+#  user_id        :bigint(8)        not null, primary key
+#  diary_entry_id :bigint(8)        not null, primary key
 #
 # Indexes
 #
index 86da87b932ac99b332e95c864f346c12cc8a7ba4..615da10767c1a9c08bf9e2895b8859df195ae239 100644 (file)
@@ -2,9 +2,9 @@
 #
 # Table name: friends
 #
-#  id             :integer          not null, primary key
-#  user_id        :integer          not null
-#  friend_user_id :integer          not null
+#  id             :bigint(8)        not null, primary key
+#  user_id        :bigint(8)        not null
+#  friend_user_id :bigint(8)        not null
 #
 # Indexes
 #
index e3a3ec921b62f25cdfa13713aabb2b2c2490f371..4ab129e9184f6593012bacd98c3de504ca06662c 100644 (file)
@@ -2,13 +2,13 @@
 #
 # Table name: messages
 #
-#  id                :integer          not null, primary key
-#  from_user_id      :integer          not null
+#  id                :bigint(8)        not null, primary key
+#  from_user_id      :bigint(8)        not null
 #  title             :string           not null
 #  body              :text             not null
 #  sent_on           :datetime         not null
 #  message_read      :boolean          default(FALSE), not null
-#  to_user_id        :integer          not null
+#  to_user_id        :bigint(8)        not null
 #  to_user_visible   :boolean          default(TRUE), not null
 #  from_user_visible :boolean          default(TRUE), not null
 #  body_format       :enum             default("markdown"), not null
index be561fb5daa3eb15b30c9810d02d9aee5aa4eda2..91a1dbc41c3bec52c9813ae66d95dbe888b4f20a 100644 (file)
@@ -2,14 +2,14 @@
 #
 # Table name: current_nodes
 #
-#  id           :integer          not null, primary key
+#  id           :bigint(8)        not null, primary key
 #  latitude     :integer          not null
 #  longitude    :integer          not null
-#  changeset_id :integer          not null
+#  changeset_id :bigint(8)        not null
 #  visible      :boolean          not null
 #  timestamp    :datetime         not null
-#  tile         :integer          not null
-#  version      :integer          not null
+#  tile         :bigint(8)        not null
+#  version      :bigint(8)        not null
 #
 # Indexes
 #
index 43915bc1265df1155f31dc51bf8b457620600bbe..86404599b266de54e2896473cbb4abfdb0b10697 100644 (file)
@@ -2,7 +2,7 @@
 #
 # Table name: current_node_tags
 #
-#  node_id :integer          not null, primary key
+#  node_id :bigint(8)        not null, primary key
 #  k       :string           default(""), not null, primary key
 #  v       :string           default(""), not null
 #
index d96addbe789f3d7f62314c0d68a12e5228fae97d..d4f9a801f41642877a0e1ca13cdb609fe11f9405 100644 (file)
@@ -2,10 +2,10 @@
 #
 # Table name: notes
 #
-#  id         :integer          not null, primary key
+#  id         :bigint(8)        not null, primary key
 #  latitude   :integer          not null
 #  longitude  :integer          not null
-#  tile       :integer          not null
+#  tile       :bigint(8)        not null
 #  updated_at :datetime         not null
 #  created_at :datetime         not null
 #  status     :enum             not null
index f94032e1e3e785a398b6e5f1d06afe195f06d331..388f890a67c4fb5ea0939be59cef429475e2ca0a 100644 (file)
@@ -2,18 +2,18 @@
 #
 # Table name: note_comments
 #
-#  id         :integer          not null, primary key
-#  note_id    :integer          not null
+#  id         :bigint(8)        not null, primary key
+#  note_id    :bigint(8)        not null
 #  visible    :boolean          not null
 #  created_at :datetime         not null
 #  author_ip  :inet
-#  author_id  :integer
+#  author_id  :bigint(8)
 #  body       :text
 #  event      :enum
 #
 # Indexes
 #
-#  index_note_comments_on_body        (to_tsvector('english'::regconfig, body))
+#  index_note_comments_on_body        (to_tsvector('english'::regconfig, body)) USING gin
 #  index_note_comments_on_created_at  (created_at)
 #  note_comments_note_id_idx          (note_id)
 #
index 9690dc46ca807106f7080f41e88e9e94048d6e78..cc2327d0883f9b1ef2034d7957c1f62c84057542 100644 (file)
@@ -2,14 +2,14 @@
 #
 # Table name: nodes
 #
-#  node_id      :integer          not null, primary key
+#  node_id      :bigint(8)        not null, primary key
 #  latitude     :integer          not null
 #  longitude    :integer          not null
-#  changeset_id :integer          not null
+#  changeset_id :bigint(8)        not null
 #  visible      :boolean          not null
 #  timestamp    :datetime         not null
-#  tile         :integer          not null
-#  version      :integer          not null, primary key
+#  tile         :bigint(8)        not null
+#  version      :bigint(8)        not null, primary key
 #  redaction_id :integer
 #
 # Indexes
index 77b78751b4684a81a720ebe3069cf441a1a6fab4..a3e1c3aaf4a49d4a22d291ab942c7cc84b4e0f32 100644 (file)
@@ -2,8 +2,8 @@
 #
 # Table name: node_tags
 #
-#  node_id :integer          not null, primary key
-#  version :integer          not null, primary key
+#  node_id :bigint(8)        not null, primary key
+#  version :bigint(8)        not null, primary key
 #  k       :string           default(""), not null, primary key
 #  v       :string           default(""), not null
 #
index 3470561cee4df036a318d2901a7c59752ae19bbd..109f7d968da1eba835f1fbcd557048ce7cd8207b 100644 (file)
@@ -2,10 +2,10 @@
 #
 # Table name: relations
 #
-#  relation_id  :integer          default(0), not null, primary key
-#  changeset_id :integer          not null
+#  relation_id  :bigint(8)        default(0), not null, primary key
+#  changeset_id :bigint(8)        not null
 #  timestamp    :datetime         not null
-#  version      :integer          not null, primary key
+#  version      :bigint(8)        not null, primary key
 #  visible      :boolean          default(TRUE), not null
 #  redaction_id :integer
 #
index a746374357d6b47a74b750e191a297646cce43ca..f8d4a359f920cfca74818bb20c935b69deaf8af6 100644 (file)
@@ -2,11 +2,11 @@
 #
 # Table name: relation_members
 #
-#  relation_id :integer          default(0), not null, primary key
+#  relation_id :bigint(8)        default(0), not null, primary key
 #  member_type :enum             not null
-#  member_id   :integer          not null
+#  member_id   :bigint(8)        not null
 #  member_role :string           not null
-#  version     :integer          default(0), not null, primary key
+#  version     :bigint(8)        default(0), not null, primary key
 #  sequence_id :integer          default(0), not null, primary key
 #
 # Indexes
index 4a247949c48c90d298e84c4c9e6034ddaf5e4bb3..c674f708bc0214a097ccc27172a7bea0d7a2e488 100644 (file)
@@ -2,10 +2,10 @@
 #
 # Table name: relation_tags
 #
-#  relation_id :integer          default(0), not null, primary key
+#  relation_id :bigint(8)        default(0), not null, primary key
 #  k           :string           default(""), not null, primary key
 #  v           :string           default(""), not null
-#  version     :integer          not null, primary key
+#  version     :bigint(8)        not null, primary key
 #
 # Foreign Keys
 #
index baca05d33549738c391d373602782515a7a94eff..31e230c3869e2ee197f46a8de823834319536c5f 100644 (file)
@@ -2,10 +2,10 @@
 #
 # Table name: ways
 #
-#  way_id       :integer          default(0), not null, primary key
-#  changeset_id :integer          not null
+#  way_id       :bigint(8)        default(0), not null, primary key
+#  changeset_id :bigint(8)        not null
 #  timestamp    :datetime         not null
-#  version      :integer          not null, primary key
+#  version      :bigint(8)        not null, primary key
 #  visible      :boolean          default(TRUE), not null
 #  redaction_id :integer
 #
index e1627d3faa3091c002bef4fbb2b0f07a56fd2492..836e76e47eb112e2764e6fc4c8876ab30cbdff17 100644 (file)
@@ -2,10 +2,10 @@
 #
 # Table name: way_nodes
 #
-#  way_id      :integer          not null, primary key
-#  node_id     :integer          not null
-#  version     :integer          not null, primary key
-#  sequence_id :integer          not null, primary key
+#  way_id      :bigint(8)        not null, primary key
+#  node_id     :bigint(8)        not null
+#  version     :bigint(8)        not null, primary key
+#  sequence_id :bigint(8)        not null, primary key
 #
 # Indexes
 #
index 5832f6d4fa2bad0addb1b093cfd83d53124ce051..ae4ad605e70b1365f27d64c714b3085ec8f16603 100644 (file)
@@ -2,10 +2,10 @@
 #
 # Table name: way_tags
 #
-#  way_id  :integer          default(0), not null, primary key
+#  way_id  :bigint(8)        default(0), not null, primary key
 #  k       :string           not null, primary key
 #  v       :string           not null
-#  version :integer          not null, primary key
+#  version :bigint(8)        not null, primary key
 #
 # Foreign Keys
 #
index e6d7487066fed12e879442d8e2cae74b9b3c1f81..d9b2a5579c5bf3b72831649b5d4d04cc5ca41326 100644 (file)
@@ -7,7 +7,7 @@
 #  description        :text
 #  created_at         :datetime
 #  updated_at         :datetime
-#  user_id            :integer          not null
+#  user_id            :bigint(8)        not null
 #  description_format :enum             default("markdown"), not null
 #
 # Foreign Keys
index 884e96ed7c120d5c20c2448753d4795df12a273e..bcac9d04bb6a3ad2cbe75ad2fe81cd57147c36b5 100644 (file)
@@ -2,11 +2,11 @@
 #
 # Table name: current_relations
 #
-#  id           :integer          not null, primary key
-#  changeset_id :integer          not null
+#  id           :bigint(8)        not null, primary key
+#  changeset_id :bigint(8)        not null
 #  timestamp    :datetime         not null
 #  visible      :boolean          not null
-#  version      :integer          not null
+#  version      :bigint(8)        not null
 #
 # Indexes
 #
index 3e5cdfca27e1513856f12c4adf04fc89e95c5bd6..7c399c3a88936b1769bb1657cf23c3db232d9e92 100644 (file)
@@ -2,9 +2,9 @@
 #
 # Table name: current_relation_members
 #
-#  relation_id :integer          not null, primary key
+#  relation_id :bigint(8)        not null, primary key
 #  member_type :enum             not null
-#  member_id   :integer          not null
+#  member_id   :bigint(8)        not null
 #  member_role :string           not null
 #  sequence_id :integer          default(0), not null, primary key
 #
index 151615f72b06272f4f634be0fba3eeed3c6ae9b7..b186f505d13142bc751f28428f2f29ce8fc7b53f 100644 (file)
@@ -2,7 +2,7 @@
 #
 # Table name: current_relation_tags
 #
-#  relation_id :integer          not null, primary key
+#  relation_id :bigint(8)        not null, primary key
 #  k           :string           default(""), not null, primary key
 #  v           :string           default(""), not null
 #
index 1a2dfc9e49a6695b10d57b1e3c97bfbdc510cf86..af2c0af3bc1c4aa5cee88c446a83b885d129d1f2 100644 (file)
@@ -2,11 +2,11 @@
 #
 # Table name: gpx_files
 #
-#  id          :integer          not null, primary key
-#  user_id     :integer          not null
+#  id          :bigint(8)        not null, primary key
+#  user_id     :bigint(8)        not null
 #  visible     :boolean          default(TRUE), not null
 #  name        :string           default(""), not null
-#  size        :integer
+#  size        :bigint(8)
 #  latitude    :float
 #  longitude   :float
 #  timestamp   :datetime         not null
index 445688c5554389e66aa90b6e77fb8dca6b354c67..6473c943031134e87a1a9d99189a07614a9066ff 100644 (file)
@@ -6,9 +6,9 @@
 #  trackid   :integer          not null
 #  latitude  :integer          not null
 #  longitude :integer          not null
-#  gpx_id    :integer          not null
+#  gpx_id    :bigint(8)        not null
 #  timestamp :datetime
-#  tile      :integer
+#  tile      :bigint(8)
 #
 # Indexes
 #
index 84b6c6dfa8394404c3757a20145e1a77a6791c82..8d2f4ffface4d307c0d1013ec212781010c8879d 100644 (file)
@@ -2,9 +2,9 @@
 #
 # Table name: gpx_file_tags
 #
-#  gpx_id :integer          default(0), not null
+#  gpx_id :bigint(8)        default(0), not null
 #  tag    :string           not null
-#  id     :integer          not null, primary key
+#  id     :bigint(8)        not null, primary key
 #
 # Indexes
 #
index dbe91ab0f95997f7349b9d1e2c5c3bc4e665cb7e..2979b13d75309cb89a392db02df4fdef3fa6dcb0 100644 (file)
@@ -3,7 +3,7 @@
 # Table name: users
 #
 #  email               :string           not null
-#  id                  :integer          not null, primary key
+#  id                  :bigint(8)        not null, primary key
 #  pass_crypt          :string           not null
 #  creation_time       :datetime         not null
 #  display_name        :string           default(""), not null
@@ -33,7 +33,7 @@
 #  image_use_gravatar  :boolean          default(FALSE), not null
 #  image_content_type  :string
 #  auth_provider       :string
-#  home_tile           :integer
+#  home_tile           :bigint(8)
 #  tou_agreed          :datetime
 #
 # Indexes
index 27bc40498b90ba455006ffd054a2eadbb3e7d60f..92cee16cd6e96bcc57e4718042c00a9cc7d57d59 100644 (file)
@@ -3,12 +3,12 @@
 # Table name: user_blocks
 #
 #  id            :integer          not null, primary key
-#  user_id       :integer          not null
-#  creator_id    :integer          not null
+#  user_id       :bigint(8)        not null
+#  creator_id    :bigint(8)        not null
 #  reason        :text             not null
 #  ends_at       :datetime         not null
 #  needs_view    :boolean          default(FALSE), not null
-#  revoker_id    :integer
+#  revoker_id    :bigint(8)
 #  created_at    :datetime
 #  updated_at    :datetime
 #  reason_format :enum             default("markdown"), not null
index 3963bd02aeb47ade7f6b47faf15293412b63c604..583ced3c56d19ed15de8dd2a4ff6922b37312de8 100644 (file)
@@ -2,7 +2,7 @@
 #
 # Table name: user_preferences
 #
-#  user_id :integer          not null, primary key
+#  user_id :bigint(8)        not null, primary key
 #  k       :string           not null, primary key
 #  v       :string           not null
 #
index adf569a03fe79a5d5827a5e33ddf4cdddb12e94d..f3d48cade4bcfeb53df717b509cc0ab90ac45d39 100644 (file)
@@ -3,11 +3,11 @@
 # Table name: user_roles
 #
 #  id         :integer          not null, primary key
-#  user_id    :integer          not null
+#  user_id    :bigint(8)        not null
 #  role       :enum             not null
 #  created_at :datetime
 #  updated_at :datetime
-#  granter_id :integer          not null
+#  granter_id :bigint(8)        not null
 #
 # Indexes
 #
index 0d1e16e8acead524674dbca9aafb58398fe6cb14..844357d8d0242000db462047ea6be54bd01342c1 100644 (file)
@@ -2,8 +2,8 @@
 #
 # Table name: user_tokens
 #
-#  id      :integer          not null, primary key
-#  user_id :integer          not null
+#  id      :bigint(8)        not null, primary key
+#  user_id :bigint(8)        not null
 #  token   :string           not null
 #  expiry  :datetime         not null
 #  referer :text
index ddb82ed1ed486965c4d4fe873decdb0e1f0f2e11..6fcaf39cc7c021801adc22e054820834430b7353 100644 (file)
@@ -2,11 +2,11 @@
 #
 # Table name: current_ways
 #
-#  id           :integer          not null, primary key
-#  changeset_id :integer          not null
+#  id           :bigint(8)        not null, primary key
+#  changeset_id :bigint(8)        not null
 #  timestamp    :datetime         not null
 #  visible      :boolean          not null
-#  version      :integer          not null
+#  version      :bigint(8)        not null
 #
 # Indexes
 #
index 5c09cd740cefc92b442ed4dcff59733e6c310aa6..0788a631c8c9c3969ea79dc84988d81fd61f58b6 100644 (file)
@@ -2,9 +2,9 @@
 #
 # Table name: current_way_nodes
 #
-#  way_id      :integer          not null, primary key
-#  node_id     :integer          not null
-#  sequence_id :integer          not null, primary key
+#  way_id      :bigint(8)        not null, primary key
+#  node_id     :bigint(8)        not null
+#  sequence_id :bigint(8)        not null, primary key
 #
 # Indexes
 #
index c4df0abb53904bf9b733ef5110f698b01dd123df..6637c158535694aa017e2719f79b067913cf9527 100644 (file)
@@ -2,7 +2,7 @@
 #
 # Table name: current_way_tags
 #
-#  way_id :integer          not null, primary key
+#  way_id :bigint(8)        not null, primary key
 #  k      :string           default(""), not null, primary key
 #  v      :string           default(""), not null
 #
diff --git a/app/views/diary_entries/_form.html.erb b/app/views/diary_entries/_form.html.erb
new file mode 100644 (file)
index 0000000..0d8f7ef
--- /dev/null
@@ -0,0 +1,35 @@
+<div class="diary_entry standard-form">
+  <fieldset>
+    <div class='form-row'>
+      <label class="standard-label"><%= t ".subject" -%></label>
+      <%= f.text_field :title, :class => "richtext_title" %>
+    </div>
+    <div class='form-row'>
+      <label class="standard-label"><%= t ".body" -%></label>
+      <%= richtext_area :diary_entry, :body, :cols => 80, :rows => 20, :format => @diary_entry.body_format %>
+    </div>
+    <div class='form-row'>
+      <label class="standard-label"><%= t ".language" -%></label>
+      <%= f.collection_select :language_code, Language.order(:english_name), :code, :name %>
+  </div>
+  </fieldset>
+  <fieldset class='location'>
+    <label class="standard-label"><%= t ".location" -%></label>
+    <%= content_tag "div", "", :id => "map", :data => { :lat => @lat, :lon => @lon, :zoom => @zoom } %>
+    <div class='form-row clearfix'>
+      <div class='form-column'>
+        <label class="secondary standard-label"><%= t ".latitude" -%></label>
+        <%= f.text_field :latitude, :size => 20, :id => "latitude" %>
+      </div>
+      <div class='form-column'>
+        <label class="secondary standard-label"><%= t ".longitude" -%></label>
+        <%= f.text_field :longitude, :size => 20, :id => "longitude" %>
+      </div>
+      <div class='form-column'>
+        <a href="#" id="usemap"><%= t ".use_map_link" -%></a>
+      </div>
+    </div>
+  </fieldset>
+
+  <%= f.submit %>
+</div>
index 62aed884c08296ee8aa61cc20135f493655ab2d8..5ea6193280c357e5d55e2036df03aad1da49bdfe 100644 (file)
@@ -8,44 +8,6 @@
 
 <%= error_messages_for "diary_entry" %>
 
-<%= form_for :diary_entry do |f| %>
-  <div class="diary_entry standard-form">
-    <fieldset>
-      <div class='form-row'>
-        <label class="standard-label"><%= t ".subject" -%></label>
-        <%= f.text_field :title, :class => "richtext_title" %>
-      </div>
-      <div class='form-row'>
-        <label class="standard-label"><%= t ".body" -%></label>
-        <%= richtext_area :diary_entry, :body, :cols => 80, :rows => 20, :format => @diary_entry.body_format %>
-      </div>
-      <div class='form-row'>
-        <label class="standard-label"><%= t ".language" -%></label>
-        <%= f.collection_select :language_code, Language.order(:english_name), :code, :name %>
-    </div>
-    </fieldset>
-    <fieldset class='location'>
-      <label class="standard-label"><%= t ".location" -%></label>
-      <%= content_tag "div", "", :id => "map", :data => { :lat => @lat, :lon => @lon, :zoom => @zoom } %>
-      <div class='form-row clearfix'>
-        <div class='form-column'>
-          <label class="secondary standard-label"><%= t ".latitude" -%></label>
-          <%= f.text_field :latitude, :size => 20, :id => "latitude" %>
-        </div>
-        <div class='form-column'>
-          <label class="secondary standard-label"><%= t ".longitude" -%></label>
-          <%= f.text_field :longitude, :size => 20, :id => "longitude" %>
-        </div>
-        <div class='form-column'>
-          <a href="#" id="usemap"><%= t ".use_map_link" -%></a>
-        </div>
-      </div>
-    </fieldset>
-
-    <% if action_name == 'new' %>
-      <%= submit_tag t("diary_entries.new.publish_button") %>
-    <% else %>
-      <%= submit_tag t(".save_button") %>
-    <% end %>
-  </div>
+<%= form_for @diary_entry, :url => diary_entry_path(current_user, @diary_entry), :html => { :method => :put } do |f| %>
+  <%= render :partial => "form", :locals => { :f => f } %>
 <% end %>
index 4e5dc994de946c43a5882510dd0486096d33b9e5..4610e5fd7403bdc45ce3598949fb9d9a958e8a75 100644 (file)
       <% if @user %>
         <% if @user == current_user %>
           <div>
-            <li><%= link_to image_tag("new.png", :class => "small_icon", :border => 0) + t(".new"), diary_new_path, :title => t(".new_title") %></li>
+            <li><%= link_to image_tag("new.png", :class => "small_icon", :border => 0) + t(".new"), new_diary_entry_path, :title => t(".new_title") %></li>
           </div>
         <% end %>
       <% else %>
         <% if current_user %>
           <div>
-            <li><%= link_to image_tag("new.png", :class => "small_icon", :border => 0) + t(".new"), diary_new_path, :title => t(".new_title") %></li>
+            <li><%= link_to image_tag("new.png", :class => "small_icon", :border => 0) + t(".new"), new_diary_entry_path, :title => t(".new_title") %></li>
           </div>
         <% end %>
       <% end %>
diff --git a/app/views/diary_entries/new.html.erb b/app/views/diary_entries/new.html.erb
new file mode 100644 (file)
index 0000000..dfe69f2
--- /dev/null
@@ -0,0 +1,13 @@
+<% content_for :head do %>
+  <%= javascript_include_tag "diary_entry" %>
+<% end %>
+
+<% content_for :heading do %>
+  <h1><%= @title %></h1>
+<% end %>
+
+<%= error_messages_for "diary_entry" %>
+
+<%= form_for @diary_entry do |f| %>
+  <%= render :partial => "form", :locals => { :f => f } %>
+<% end %>
index a2a63b406af9e017bd053937de60c679f4679dbf..725000a1364bd2dd0a6ca9fc343f494ce2f2be08 100644 (file)
@@ -49,7 +49,7 @@
         </li>
       <% end %>
       <li class="compact-hide <%= current_page_class(traces_path) %>"><%= link_to t("layouts.gps_traces"), traces_path %></li>
-      <li class="compact-hide <%= current_page_class(diary_path) %>"><%= link_to t("layouts.user_diaries"), diary_path %></li>
+      <li class="compact-hide <%= current_page_class(diary_entries_path) %>"><%= link_to t("layouts.user_diaries"), diary_entries_path %></li>
       <li class="compact-hide <%= current_page_class(copyright_path) %>"><%= link_to t("layouts.copyright"), copyright_path %></li>
       <li class="compact-hide <%= current_page_class(help_path) %>"><%= link_to t("layouts.help"), help_path %></li>
       <li class="compact-hide <%= current_page_class(about_path) %>"><%= link_to t("layouts.about"), about_path %></li>
@@ -65,7 +65,7 @@
             </li>
           <% end %>
           <li class="<%= current_page_class(traces_path) %>"><%= link_to t("layouts.gps_traces"), traces_path %></li>
-          <li class="<%= current_page_class(diary_path) %>"><%= link_to t("layouts.user_diaries"), diary_path %></li>
+          <li class="<%= current_page_class(diary_entries_path) %>"><%= link_to t("layouts.user_diaries"), diary_entries_path %></li>
           <li class="<%= current_page_class(copyright_path) %>"><%= link_to t("layouts.copyright"), copyright_path %></li>
           <li class="<%= current_page_class(help_path) %>"><%= link_to t("layouts.help"), help_path %></li>
           <li class="<%= current_page_class(about_path) %>"><%= link_to t("layouts.about"), about_path %></li>
index 219e0ab6b0df3cf11e5eb9f0cd58f5414e25595a..886aaf006434f9069aee2338a74a5aa9d39a9cd2 100644 (file)
@@ -17,7 +17,7 @@
 
   <div class='section'>
     <h2><div class='icon community'></div><%= t ".community_driven_title" %></h2>
-    <p><%= t ".community_driven_html", :diary_path => diary_path %></p>
+    <p><%= t ".community_driven_html", :diary_path => diary_entries_path %></p>
   </div>
 
   <div class='section' id='open-data'>
index 5090cbee07a2e90284e033221c94a594f8ba3d4a..87eb9b45feb1c44027c7317e679820d79e8334c5 100644 (file)
     <% else %>
       <ul class='secondary-actions clearfix'>
         <li><%= link_to t(".friends_changesets"), friend_changesets_path %></li>
-        <li><%= link_to t(".friends_diaries"), friend_diaries_path %></li>
+        <li><%= link_to t(".friends_diaries"), friends_diary_entries_path %></li>
       </ul>
       <div id="friends-container">
         <%= render :partial => "contact", :collection => friends, :locals => { :type => "friend" } %>
     <% else %>
       <ul class='secondary-actions clearfix'>
         <li><%= link_to t(".nearby_changesets"), nearby_changesets_path %></li>
-        <li><%= link_to t(".nearby_diaries"), nearby_diaries_path %></li>
+        <li><%= link_to t(".nearby_diaries"), nearby_diary_entries_path %></li>
       </ul>
       <div id="nearbyusers">
         <%= render :partial => "contact", :collection => nearby, :locals => { :type => "nearby mapper" } %>
index 575c361bb142447125bbca0c5d0cf485d6bcb4c5..ec65912263cbbcb72a458fa15b027fdfc7d2f25d 100644 (file)
@@ -5,6 +5,11 @@ en:
     formats:
       friendly: "%e %B %Y at %H:%M"
       blog: "%e %B %Y"
+  helpers:
+    submit:
+      diary_entry:
+        create: "Publish"
+        update: "Update"
   activerecord:
     errors:
       messages:
@@ -282,7 +287,14 @@ en:
   diary_entries:
     new:
       title: New Diary Entry
-      publish_button: "Publish"
+    form:
+      subject: "Subject:"
+      body: "Body:"
+      language: "Language:"
+      location: "Location:"
+      latitude: "Latitude:"
+      longitude: "Longitude:"
+      use_map_link: "use map"
     index:
       title: "Users' diaries"
       title_friends: "Friends' diaries"
@@ -296,15 +308,7 @@ en:
       older_entries: Older Entries
       newer_entries: Newer Entries
     edit:
-      title: "Edit diary entry"
-      subject: "Subject:"
-      body: "Body:"
-      language: "Language:"
-      location: "Location:"
-      latitude: "Latitude:"
-      longitude: "Longitude:"
-      use_map_link: "use map"
-      save_button: "Save"
+      title: Edit Diary Entry
       marker_text: Diary entry location
     show:
       title: "%{user}'s diary | %{title}"
index 1989325830543c08d93e3504b7e68022de7b8eb0..63ce061672a559ccdf87622093972ad5eac2800f 100644 (file)
@@ -216,9 +216,12 @@ OpenStreetMap::Application.routes.draw do
   post "/trace/:id/delete" => "traces#delete", :id => /\d+/
 
   # diary pages
-  match "/diary/new" => "diary_entries#new", :via => [:get, :post]
-  get "/diary/friends" => "diary_entries#index", :friends => true, :as => "friend_diaries"
-  get "/diary/nearby" => "diary_entries#index", :nearby => true, :as => "nearby_diaries"
+  resources :diary_entries, :path => "diary", :only => [:new, :create, :index] do
+    collection do
+      get "friends" => "diary_entries#index", :friends => true
+      get "nearby" => "diary_entries#index", :nearby => true
+    end
+  end
   get "/user/:display_name/diary/rss" => "diary_entries#rss", :defaults => { :format => :rss }
   get "/diary/:language/rss" => "diary_entries#rss", :defaults => { :format => :rss }
   get "/diary/rss" => "diary_entries#rss", :defaults => { :format => :rss }
@@ -226,10 +229,10 @@ OpenStreetMap::Application.routes.draw do
   get "/user/:display_name/diary/comments/" => "diary_entries#comments"
   get "/user/:display_name/diary" => "diary_entries#index"
   get "/diary/:language" => "diary_entries#index"
-  get "/diary" => "diary_entries#index"
-  get "/user/:display_name/diary/:id" => "diary_entries#show", :id => /\d+/, :as => :diary_entry
+  scope "/user/:display_name" do
+    resources :diary_entries, :path => "diary", :only => [:edit, :update, :show]
+  end
   post "/user/:display_name/diary/:id/newcomment" => "diary_entries#comment", :id => /\d+/
-  match "/user/:display_name/diary/:id/edit" => "diary_entries#edit", :via => [:get, :post], :id => /\d+/
   post "/user/:display_name/diary/:id/hide" => "diary_entries#hide", :id => /\d+/, :as => :hide_diary_entry
   post "/user/:display_name/diary/:id/hidecomment/:comment" => "diary_entries#hidecomment", :id => /\d+/, :comment => /\d+/, :as => :hide_diary_comment
   post "/user/:display_name/diary/:id/subscribe" => "diary_entries#subscribe", :as => :diary_entry_subscribe, :id => /\d+/
index 6031f06547f91406e9b607a0613561ced31dfd37..51d3ed2c9e1f792949e1eb47bf8e2308063863a1 100644 (file)
@@ -57,6 +57,8 @@ nearby_users: 30
 nearby_radius: 50
 # Spam threshold
 spam_threshold: 50
+# Delay diary entries from appearing in the feed for this many hours
+diary_feed_delay: 0
 # Default legale (jurisdiction location) for contributor terms
 default_legale: GB
 # Use the built-in jobs queue for importing traces
index 022c9324633250247b2088d66b1d7853c973998f..e9a506c414fc1b4ce5a8676934e33456efa72399 100644 (file)
@@ -1,6 +1,8 @@
 # Trace directories for testing
 gpx_trace_dir: <%= Rails.root.join("test", "gpx", "traces") %>
 gpx_image_dir: <%= Rails.root.join("test", "gpx", "images") %>
+# Ignore the diary feed delay unless we're specifically testing it
+diary_feed_delay: 0
 # Geonames credentials for testing
 geonames_username: "dummy"
 # External authentication credentials for testing
index b1f2216c792e26eb39778be0e738f48982e62e43..71684c65e74366e8235010b6ba1504f479f6abee 100644 (file)
@@ -62,8 +62,8 @@ class DiaryEntriesControllerTest < ActionController::TestCase
       { :controller => "diary_entries", :action => "new" }
     )
     assert_routing(
-      { :path => "/diary/new", :method => :post },
-      { :controller => "diary_entries", :action => "new" }
+      { :path => "/diary", :method => :post },
+      { :controller => "diary_entries", :action => "create" }
     )
     assert_routing(
       { :path => "/user/username/diary/1", :method => :get },
@@ -74,8 +74,8 @@ class DiaryEntriesControllerTest < ActionController::TestCase
       { :controller => "diary_entries", :action => "edit", :display_name => "username", :id => "1" }
     )
     assert_routing(
-      { :path => "/user/username/diary/1/edit", :method => :post },
-      { :controller => "diary_entries", :action => "edit", :display_name => "username", :id => "1" }
+      { :path => "/user/username/diary/1", :method => :put },
+      { :controller => "diary_entries", :action => "update", :display_name => "username", :id => "1" }
     )
     assert_routing(
       { :path => "/user/username/diary/1/newcomment", :method => :post },
@@ -116,7 +116,7 @@ class DiaryEntriesControllerTest < ActionController::TestCase
       assert_select "h1", :text => /New Diary Entry/, :count => 1
     end
     assert_select "div#content", :count => 1 do
-      assert_select "form[action='/diary/new'][method=post]", :count => 1 do
+      assert_select "form[action='/diary'][method=post]", :count => 1 do
         assert_select "input#diary_entry_title[name='diary_entry[title]']", :count => 1
         assert_select "textarea#diary_entry_body[name='diary_entry[body]']", :text => "", :count => 1
         assert_select "select#diary_entry_language_code", :count => 1
@@ -140,30 +140,30 @@ class DiaryEntriesControllerTest < ActionController::TestCase
           :session => { :user => create(:user).id }
     end
     assert_response :success
-    assert_template :edit
+    assert_template :new
   end
 
-  def test_new_no_body
+  def test_create_no_body
     # Now try creating a invalid diary entry with an empty body
     user = create(:user)
     assert_no_difference "DiaryEntry.count" do
-      post :new,
+      post :create,
            :params => { :commit => "save",
                         :diary_entry => { :title => "New Title", :body => "", :latitude => "1.1",
                                           :longitude => "2.2", :language_code => "en" } },
            :session => { :user => user.id }
     end
     assert_response :success
-    assert_template :edit
+    assert_template :new
 
     assert_nil UserPreference.where(:user_id => user.id, :k => "diary.default_language").first
   end
 
-  def test_new_post
+  def test_create
     # Now try creating a diary entry
     user = create(:user)
     assert_difference "DiaryEntry.count", 1 do
-      post :new,
+      post :create,
            :params => { :commit => "save",
                         :diary_entry => { :title => "New Title", :body => "This is a new body for the diary entry", :latitude => "1.1",
                                           :longitude => "2.2", :language_code => "en" } },
@@ -185,13 +185,13 @@ class DiaryEntriesControllerTest < ActionController::TestCase
     assert_equal "en", UserPreference.where(:user_id => user.id, :k => "diary.default_language").first.v
   end
 
-  def test_new_german
+  def test_create_german
     create(:language, :code => "de")
     user = create(:user)
 
     # Now try creating a diary entry in a different language
     assert_difference "DiaryEntry.count", 1 do
-      post :new,
+      post :create,
            :params => { :commit => "save",
                         :diary_entry => { :title => "New Title", :body => "This is a new body for the diary entry", :latitude => "1.1",
                                           :longitude => "2.2", :language_code => "de" } },
@@ -221,7 +221,7 @@ class DiaryEntriesControllerTest < ActionController::TestCase
 
     # Try creating a spammy diary entry
     assert_difference "DiaryEntry.count", 1 do
-      post :new,
+      post :create,
            :params => { :commit => "save",
                         :diary_entry => { :title => spammy_title, :body => spammy_body, :language_code => "en" } },
            :session => { :user => user.id }
@@ -279,21 +279,21 @@ class DiaryEntriesControllerTest < ActionController::TestCase
         :params => { :display_name => entry.user.display_name, :id => entry.id },
         :session => { :user => entry.user }
     assert_response :success
-    assert_select "title", :text => /Edit diary entry/, :count => 1
+    assert_select "title", :text => /Edit Diary Entry/, :count => 1
     assert_select "div.content-heading", :count => 1 do
-      assert_select "h1", :text => /Edit diary entry/, :count => 1
+      assert_select "h1", :text => /Edit Diary Entry/, :count => 1
     end
     assert_select "div#content", :count => 1 do
-      assert_select "form[action='/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}/edit'][method=post]", :count => 1 do
+      assert_select "form[action='/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}'][method=post]", :count => 1 do
         assert_select "input#diary_entry_title[name='diary_entry[title]'][value='#{entry.title}']", :count => 1
         assert_select "textarea#diary_entry_body[name='diary_entry[body]']", :text => entry.body, :count => 1
         assert_select "select#diary_entry_language_code", :count => 1
         assert_select "input#latitude[name='diary_entry[latitude]']", :count => 1
         assert_select "input#longitude[name='diary_entry[longitude]']", :count => 1
-        assert_select "input[name=commit][type=submit][value=Save]", :count => 1
+        assert_select "input[name=commit][type=submit][value=Update]", :count => 1
         assert_select "input[name=commit][type=submit][value=Edit]", :count => 1
         assert_select "input[name=commit][type=submit][value=Preview]", :count => 1
-        assert_select "input", :count => 7
+        assert_select "input", :count => 8
       end
     end
 
@@ -303,11 +303,11 @@ class DiaryEntriesControllerTest < ActionController::TestCase
     new_latitude = "1.1"
     new_longitude = "2.2"
     new_language_code = "en"
-    post :edit,
-         :params => { :display_name => entry.user.display_name, :id => entry.id, :commit => "save",
-                      :diary_entry => { :title => new_title, :body => new_body, :latitude => new_latitude,
-                                        :longitude => new_longitude, :language_code => new_language_code } },
-         :session => { :user => entry.user.id }
+    put :update,
+        :params => { :display_name => entry.user.display_name, :id => entry.id, :commit => "save",
+                     :diary_entry => { :title => new_title, :body => new_body, :latitude => new_latitude,
+                                       :longitude => new_longitude, :language_code => new_language_code } },
+        :session => { :user => entry.user.id }
     assert_response :redirect
     assert_redirected_to :action => :show, :display_name => entry.user.display_name, :id => entry.id
 
@@ -664,6 +664,18 @@ class DiaryEntriesControllerTest < ActionController::TestCase
     assert_match "<title>&lt;script&gt;</title>", response.body
   end
 
+  def test_feed_delay
+    create(:diary_entry, :created_at => 7.hours.ago)
+    create(:diary_entry, :created_at => 5.hours.ago)
+    get :rss, :params => { :format => :rss }
+    assert_select "rss>channel>item", :count => 2
+
+    with_diary_feed_delay(6) do
+      get :rss, :params => { :format => :rss }
+      assert_select "rss>channel>item", :count => 1
+    end
+  end
+
   def test_show
     user = create(:user)
     suspended_user = create(:user, :suspended)
@@ -897,4 +909,13 @@ class DiaryEntriesControllerTest < ActionController::TestCase
       assert_select "a[href=?]", "/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}"
     end
   end
+
+  def with_diary_feed_delay(value)
+    diary_feed_delay = Settings.diary_feed_delay
+    Settings.diary_feed_delay = value
+
+    yield
+
+    Settings.diary_feed_delay = diary_feed_delay
+  end
 end
index df2e7d8f52a5420e9dcd987ee5febb68763e90c1..5dbd866a960f6fb74ec423f8bae97822b67c05b5 100644 (file)
@@ -445,34 +445,34 @@ class UsersControllerTest < ActionController::TestCase
   def test_confirm_success_no_token_with_referer
     user = create(:user, :pending)
     stub_gravatar_request(user.email)
-    confirm_string = user.tokens.create(:referer => diary_new_path).token
+    confirm_string = user.tokens.create(:referer => new_diary_entry_path).token
 
     @request.cookies["_osm_session"] = user.display_name
     post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
-    assert_redirected_to login_path(:referer => diary_new_path)
+    assert_redirected_to login_path(:referer => new_diary_entry_path)
     assert_match(/Confirmed your account/, flash[:notice])
   end
 
   def test_confirm_success_good_token_with_referer
     user = create(:user, :pending)
     stub_gravatar_request(user.email)
-    confirm_string = user.tokens.create(:referer => diary_new_path).token
+    confirm_string = user.tokens.create(:referer => new_diary_entry_path).token
     token = user.tokens.create.token
 
     @request.cookies["_osm_session"] = user.display_name
     post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string }, :session => { :token => token }
-    assert_redirected_to diary_new_path
+    assert_redirected_to new_diary_entry_path
   end
 
   def test_confirm_success_bad_token_with_referer
     user = create(:user, :pending)
     stub_gravatar_request(user.email)
-    confirm_string = user.tokens.create(:referer => diary_new_path).token
+    confirm_string = user.tokens.create(:referer => new_diary_entry_path).token
     token = create(:user).tokens.create.token
 
     @request.cookies["_osm_session"] = user.display_name
     post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string }, :session => { :token => token }
-    assert_redirected_to login_path(:referer => diary_new_path)
+    assert_redirected_to login_path(:referer => new_diary_entry_path)
     assert_match(/Confirmed your account/, flash[:notice])
   end
 
@@ -488,7 +488,7 @@ class UsersControllerTest < ActionController::TestCase
 
   def test_confirm_already_confirmed
     user = create(:user)
-    confirm_string = user.tokens.create(:referer => diary_new_path).token
+    confirm_string = user.tokens.create(:referer => new_diary_entry_path).token
 
     @request.cookies["_osm_session"] = user.display_name
     post :confirm, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
index 026028d5f23d83e44073a2a814966c4160ef9ec7..e090342c1bd962cd18636b4b737ffbea8dd41a49 100644 (file)
@@ -29,7 +29,7 @@ class UserDiariesTest < ActionDispatch::IntegrationTest
     follow_redirect!
 
     assert_response :success
-    assert_template "diary_entries/edit"
+    assert_template "diary_entries/new"
     # print @response.body
     # print @html_document.to_yaml
 
@@ -42,7 +42,7 @@ class UserDiariesTest < ActionDispatch::IntegrationTest
       assert_select "h1", "New Diary Entry"
     end
     assert_select "div#content" do
-      assert_select "form[action='/diary/new']" do
+      assert_select "form[action='/diary']" do
         assert_select "input[id=diary_entry_title]"
       end
     end
index 39ccc04b26be946f9689a1011b5b78ec0bb1f513..6b6a51de553f554df76fc68ae305164ea504e084 100644 (file)
@@ -8,7 +8,7 @@ class DiaryEntrySystemTest < ApplicationSystemTestCase
 
   test "reply to diary entry should prefill the message subject" do
     sign_in_as(create(:user))
-    visit diary_path
+    visit diary_entries_path
 
     click_on "Reply to this entry"