Rename comment to create
This commit is contained in:
parent
19c2b92fb7
commit
b7e871cb46
3 changed files with 16 additions and 16 deletions
|
@ -1,12 +1,12 @@
|
||||||
class ChangesetCommentsController < ApplicationController
|
class ChangesetCommentsController < ApplicationController
|
||||||
before_action :authorize_web, :only => [:comments_feed]
|
before_action :authorize_web, :only => [:comments_feed]
|
||||||
before_action :set_locale, :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_allow_write_api, :only => [:create, :hide_comment, :unhide_comment]
|
||||||
before_action :require_public_data, :only => [:comment]
|
before_action :require_public_data, :only => [:create]
|
||||||
before_action :check_api_writable, :only => [:comment, :hide_comment, :unhide_comment]
|
before_action :check_api_writable, :only => [:create, :hide_comment, :unhide_comment]
|
||||||
before_action :check_api_readable, :except => [:comment, :comments_feed]
|
before_action :check_api_readable, :except => [:create, :comments_feed]
|
||||||
before_action(:only => [:comments_feed]) { |c| c.check_database_readable(true) }
|
before_action(:only => [:comments_feed]) { |c| c.check_database_readable(true) }
|
||||||
around_action :api_call_handle_error, :except => [:comments_feed]
|
around_action :api_call_handle_error, :except => [:comments_feed]
|
||||||
around_action :api_call_timeout, :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
|
# Check the arguments are sane
|
||||||
raise OSM::APIBadUserInput, "No id was given" unless params[:id]
|
raise OSM::APIBadUserInput, "No id was given" unless params[:id]
|
||||||
raise OSM::APIBadUserInput, "No text was given" if params[:text].blank?
|
raise OSM::APIBadUserInput, "No text was given" if params[:text].blank?
|
||||||
|
|
|
@ -16,7 +16,7 @@ OpenStreetMap::Application.routes.draw do
|
||||||
put "changeset/:id" => "changeset#update", :id => /\d+/
|
put "changeset/:id" => "changeset#update", :id => /\d+/
|
||||||
put "changeset/:id/close" => "changeset#close", :id => /\d+/
|
put "changeset/:id/close" => "changeset#close", :id => /\d+/
|
||||||
get "changesets" => "changeset#query"
|
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/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/unhide" => "changeset_comments#unhide_comment", :as => :changeset_comment_unhide, :id => /\d+/
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ class ChangesetCommentsControllerTest < ActionController::TestCase
|
||||||
def test_routes
|
def test_routes
|
||||||
assert_routing(
|
assert_routing(
|
||||||
{ :path => "/api/0.6/changeset/1/comment", :method => :post },
|
{ :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(
|
assert_routing(
|
||||||
{ :path => "/api/0.6/changeset/comment/1/hide", :method => :post },
|
{ :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_difference "ChangesetComment.count", 1 do
|
||||||
assert_no_difference "ActionMailer::Base.deliveries.size" do
|
assert_no_difference "ActionMailer::Base.deliveries.size" do
|
||||||
perform_enqueued_jobs 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 "ChangesetComment.count", 1 do
|
||||||
assert_difference "ActionMailer::Base.deliveries.size", 1 do
|
assert_difference "ActionMailer::Base.deliveries.size", 1 do
|
||||||
perform_enqueued_jobs 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 "ChangesetComment.count", 1 do
|
||||||
assert_difference "ActionMailer::Base.deliveries.size", 2 do
|
assert_difference "ActionMailer::Base.deliveries.size", 2 do
|
||||||
perform_enqueued_jobs 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
|
# create comment fail
|
||||||
def test_create_comment_fail
|
def test_create_comment_fail
|
||||||
# unauthorized
|
# 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
|
assert_response :unauthorized
|
||||||
|
|
||||||
basic_authorization create(:user).email, "test"
|
basic_authorization create(:user).email, "test"
|
||||||
|
|
||||||
# bad changeset id
|
# bad changeset id
|
||||||
assert_no_difference "ChangesetComment.count" do
|
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
|
end
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
|
|
||||||
# not closed changeset
|
# not closed changeset
|
||||||
assert_no_difference "ChangesetComment.count" do
|
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
|
end
|
||||||
assert_response :conflict
|
assert_response :conflict
|
||||||
|
|
||||||
# no text
|
# no text
|
||||||
assert_no_difference "ChangesetComment.count" do
|
assert_no_difference "ChangesetComment.count" do
|
||||||
post :comment, :params => { :id => create(:changeset, :closed).id }
|
post :create, :params => { :id => create(:changeset, :closed).id }
|
||||||
end
|
end
|
||||||
assert_response :bad_request
|
assert_response :bad_request
|
||||||
|
|
||||||
# empty text
|
# empty text
|
||||||
assert_no_difference "ChangesetComment.count" do
|
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
|
end
|
||||||
assert_response :bad_request
|
assert_response :bad_request
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue