Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/pull/5408'
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Dec 17, 2024
2 parents ca719af + ca4ee6f commit 18409c0
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/controllers/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@ def show
render :template => "browse/not_found", :status => :not_found
end

def new; end
def new
render :action => :new_readonly if api_status != "online"
end
end
7 changes: 7 additions & 0 deletions app/views/notes/new_readonly.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<% set_title(t(".title")) %>

<%= render "sidebar_header", :title => t(".title") %>

<div class="note">
<p class="alert alert-warning"><%= t(".warning") %></p>
</div>
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3053,6 +3053,9 @@ en:
anonymous_warning_sign_up: "sign up"
advice: "Your note is public and may be used to update the map, so don't enter personal information, or information from copyrighted maps or directory listings."
add: Add Note
new_readonly:
title: "New Note"
warning: "New notes cannot be created because the OpenStreetMap API is currently in read-only mode."
notes_paging_nav:
showing_page: "Page %{page}"
next: "Next"
Expand Down
23 changes: 23 additions & 0 deletions test/system/create_note_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require "application_system_test_case"

class CreateNoteTest < ApplicationSystemTestCase
test "can create note" do
visit new_note_path(:anchor => "map=18/0/0")

assert_button "Add Note", :disabled => true

fill_in "text", :with => "Some newly added note description"
click_on "Add Note"

assert_content "Unresolved note ##{Note.last.id}"
assert_content "Some newly added note description"
end

test "cannot create note when api is readonly" do
with_settings(:status => "api_readonly") do
visit new_note_path(:anchor => "map=18/0/0")

assert_no_button "Add Note", :disabled => true
end
end
end

0 comments on commit 18409c0

Please sign in to comment.