Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions plugin.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
# name: discourse-locations
# about: Tools for handling locations in Discourse
# version: 6.3.10
# version: 6.3.11
# authors: Angus McLeod, Robert Barrow
# contact_emails: development@pavilion.tech
# url: https://github.com/angusmcleod/discourse-locations
Expand Down Expand Up @@ -185,7 +185,12 @@ class Engine < ::Rails::Engine
raise Discourse::InvalidParameters.new, I18n.t('location.errors.invalid')
end

result[:custom_fields][:geo_location] = params[:custom_fields][:geo_location]
if params &&
params[:custom_fields] &&
params[:custom_fields][:geo_location]
result[:custom_fields][:geo_location] = params[:custom_fields][:geo_location]
end

result
end

Expand Down
15 changes: 15 additions & 0 deletions spec/requests/user_controller_location_update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

RSpec.describe UsersController do
fab!(:user) { Fabricate(:user) }
user_field = Fabricate(:user_field, editable: true)
before do
sign_in(user)
SiteSetting.location_enabled = true
Expand Down Expand Up @@ -37,5 +38,19 @@
result = response.parsed_body
expect(result["error_type"]).to eq("invalid_parameters")
end

it "allows user to upload a different custom user field who doesn't have a location" do
put "/u/#{user.username}.json",
params: {
user_fields: {
user_field.id.to_s => "happy",
},
}

expect(response.status).to eq(200)
result = response.parsed_body
expect(result["success"]).to eq("OK")
expect(user.user_fields[user_field.id.to_s]).to eq("happy")
end
end
end