]> git.openstreetmap.org Git - rails.git/commitdiff
Rename comment to create
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 31 Oct 2018 19:01:01 +0000 (20:01 +0100)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 7 Nov 2018 09:22:07 +0000 (10:22 +0100)
app/controllers/changeset_comments_controller.rb
config/routes.rb
test/controllers/changeset_comments_controller_test.rb

index 31e152560af73d8fe0353a41fc6141822044a8b8..21bd58e65394d2ab5d7015c2f2bcb1174b0d4a54 100644 (file)
@@ -1,12 +1,12 @@
 class ChangesetCommentsController < ApplicationController
   before_action :authorize_web, :only => [:comments_feed]
   before_action :set_locale, :only => [:comments_feed]
 class ChangesetCommentsController < ApplicationController
   before_action :authorize_web, :only => [:comments_feed]
   before_action :set_locale, :only => [:comments_feed]
-  before_action :authorize, :only => [:comment, :hide_comment, :unhide_comment]
+  before_action :authorize, :only => [:create, :hide_comment, :unhide_comment]
   before_action :require_moderator, :only => [:hide_comment, :unhide_comment]
   before_action :require_moderator, :only => [:hide_comment, :unhide_comment]
-  before_action :require_allow_write_api, :only => [:comment, :hide_comment, :unhide_comment]
-  before_action :require_public_data, :only => [:comment]
-  before_action :check_api_writable, :only => [:comment, :hide_comment, :unhide_comment]
-  before_action :check_api_readable, :except => [:comment, :comments_feed]
+  before_action :require_allow_write_api, :only => [:create, :hide_comment, :unhide_comment]
+  before_action :require_public_data, :only => [:create]
+  before_action :check_api_writable, :only => [:create, :hide_comment, :unhide_comment]
+  before_action :check_api_readable, :except => [:create, :comments_feed]
   before_action(:only => [:comments_feed]) { |c| c.check_database_readable(true) }
   around_action :api_call_handle_error, :except => [:comments_feed]
   around_action :api_call_timeout, :except => [:comments_feed]
   before_action(:only => [:comments_feed]) { |c| c.check_database_readable(true) }
   around_action :api_call_handle_error, :except => [:comments_feed]
   around_action :api_call_timeout, :except => [:comments_feed]
@@ -14,7 +14,7 @@ class ChangesetCommentsController < ApplicationController
 
   ##
   # Add a comment to a changeset
 
   ##
   # Add a comment to a changeset
-  def comment
+  def create
     # Check the arguments are sane
     raise OSM::APIBadUserInput, "No id was given" unless params[:id]
     raise OSM::APIBadUserInput, "No text was given" if params[:text].blank?
     # Check the arguments are sane
     raise OSM::APIBadUserInput, "No id was given" unless params[:id]
     raise OSM::APIBadUserInput, "No text was given" if params[:text].blank?
index 38ce38aa2fe04a037081cfe1f48b9025f22f67af..cf4fefcda8f3efcdce81ce00a4c6d122e240518c 100644 (file)
@@ -16,7 +16,7 @@ OpenStreetMap::Application.routes.draw do
     put "changeset/:id" => "changeset#update", :id => /\d+/
     put "changeset/:id/close" => "changeset#close", :id => /\d+/
     get "changesets" => "changeset#query"
     put "changeset/:id" => "changeset#update", :id => /\d+/
     put "changeset/:id/close" => "changeset#close", :id => /\d+/
     get "changesets" => "changeset#query"
-    post "changeset/:id/comment" => "changeset_comments#comment", :as => :changeset_comment, :id => /\d+/
+    post "changeset/:id/comment" => "changeset_comments#create", :as => :changeset_comment, :id => /\d+/
     post "changeset/comment/:id/hide" => "changeset_comments#hide_comment", :as => :changeset_comment_hide, :id => /\d+/
     post "changeset/comment/:id/unhide" => "changeset_comments#unhide_comment", :as => :changeset_comment_unhide, :id => /\d+/
 
     post "changeset/comment/:id/hide" => "changeset_comments#hide_comment", :as => :changeset_comment_hide, :id => /\d+/
     post "changeset/comment/:id/unhide" => "changeset_comments#unhide_comment", :as => :changeset_comment_unhide, :id => /\d+/
 
index 215f45957a11cd31af314acb7899165809e2bd46..ed15d34a892c9632156b32390b371d57497ac0cd 100644 (file)
@@ -6,7 +6,7 @@ class ChangesetCommentsControllerTest < ActionController::TestCase
   def test_routes
     assert_routing(
       { :path => "/api/0.6/changeset/1/comment", :method => :post },
   def test_routes
     assert_routing(
       { :path => "/api/0.6/changeset/1/comment", :method => :post },
-      { :controller => "changeset_comments", :action => "comment", :id => "1" }
+      { :controller => "changeset_comments", :action => "create", :id => "1" }
     )
     assert_routing(
       { :path => "/api/0.6/changeset/comment/1/hide", :method => :post },
     )
     assert_routing(
       { :path => "/api/0.6/changeset/comment/1/hide", :method => :post },
@@ -41,7 +41,7 @@ class ChangesetCommentsControllerTest < ActionController::TestCase
     assert_difference "ChangesetComment.count", 1 do
       assert_no_difference "ActionMailer::Base.deliveries.size" do
         perform_enqueued_jobs do
     assert_difference "ChangesetComment.count", 1 do
       assert_no_difference "ActionMailer::Base.deliveries.size" do
         perform_enqueued_jobs do
-          post :comment, :params => { :id => private_user_closed_changeset.id, :text => "This is a comment" }
+          post :create, :params => { :id => private_user_closed_changeset.id, :text => "This is a comment" }
         end
       end
     end
         end
       end
     end
@@ -56,7 +56,7 @@ class ChangesetCommentsControllerTest < ActionController::TestCase
     assert_difference "ChangesetComment.count", 1 do
       assert_difference "ActionMailer::Base.deliveries.size", 1 do
         perform_enqueued_jobs do
     assert_difference "ChangesetComment.count", 1 do
       assert_difference "ActionMailer::Base.deliveries.size", 1 do
         perform_enqueued_jobs do
-          post :comment, :params => { :id => changeset.id, :text => "This is a comment" }
+          post :create, :params => { :id => changeset.id, :text => "This is a comment" }
         end
       end
     end
         end
       end
     end
@@ -74,7 +74,7 @@ class ChangesetCommentsControllerTest < ActionController::TestCase
     assert_difference "ChangesetComment.count", 1 do
       assert_difference "ActionMailer::Base.deliveries.size", 2 do
         perform_enqueued_jobs do
     assert_difference "ChangesetComment.count", 1 do
       assert_difference "ActionMailer::Base.deliveries.size", 2 do
         perform_enqueued_jobs do
-          post :comment, :params => { :id => changeset.id, :text => "This is a comment" }
+          post :create, :params => { :id => changeset.id, :text => "This is a comment" }
         end
       end
     end
         end
       end
     end
@@ -97,32 +97,32 @@ class ChangesetCommentsControllerTest < ActionController::TestCase
   # create comment fail
   def test_create_comment_fail
     # unauthorized
   # create comment fail
   def test_create_comment_fail
     # unauthorized
-    post :comment, :params => { :id => create(:changeset, :closed).id, :text => "This is a comment" }
+    post :create, :params => { :id => create(:changeset, :closed).id, :text => "This is a comment" }
     assert_response :unauthorized
 
     basic_authorization create(:user).email, "test"
 
     # bad changeset id
     assert_no_difference "ChangesetComment.count" do
     assert_response :unauthorized
 
     basic_authorization create(:user).email, "test"
 
     # bad changeset id
     assert_no_difference "ChangesetComment.count" do
-      post :comment, :params => { :id => 999111, :text => "This is a comment" }
+      post :create, :params => { :id => 999111, :text => "This is a comment" }
     end
     assert_response :not_found
 
     # not closed changeset
     assert_no_difference "ChangesetComment.count" do
     end
     assert_response :not_found
 
     # not closed changeset
     assert_no_difference "ChangesetComment.count" do
-      post :comment, :params => { :id => create(:changeset).id, :text => "This is a comment" }
+      post :create, :params => { :id => create(:changeset).id, :text => "This is a comment" }
     end
     assert_response :conflict
 
     # no text
     assert_no_difference "ChangesetComment.count" do
     end
     assert_response :conflict
 
     # no text
     assert_no_difference "ChangesetComment.count" do
-      post :comment, :params => { :id => create(:changeset, :closed).id }
+      post :create, :params => { :id => create(:changeset, :closed).id }
     end
     assert_response :bad_request
 
     # empty text
     assert_no_difference "ChangesetComment.count" do
     end
     assert_response :bad_request
 
     # empty text
     assert_no_difference "ChangesetComment.count" do
-      post :comment, :params => { :id => create(:changeset, :closed).id, :text => "" }
+      post :create, :params => { :id => create(:changeset, :closed).id, :text => "" }
     end
     assert_response :bad_request
   end
     end
     assert_response :bad_request
   end