mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:47:22 +08:00
FIX: Incorrect route for updating username.
This commit is contained in:
parent
ddd299f4aa
commit
d8541c589a
|
@ -254,7 +254,7 @@ const User = RestModel.extend({
|
|||
|
||||
// TODO: We can remove this when migrated fully to rest model.
|
||||
this.set('isSaving', true);
|
||||
return ajax(`/users/${this.get('username_lower')}`, {
|
||||
return ajax(`/users/${this.get('username_lower')}.json`, {
|
||||
data: data,
|
||||
type: 'PUT'
|
||||
}).then(result => {
|
||||
|
|
|
@ -327,7 +327,7 @@ Discourse::Application.routes.draw do
|
|||
|
||||
get "users/:username.json" => "users#show", constraints: {username: USERNAME_ROUTE_FORMAT}, defaults: {format: :json}
|
||||
get "users/:username" => "users#show", as: 'user', constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
put "users/:username" => "users#update", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
put "users/:username" => "users#update", constraints: {username: USERNAME_ROUTE_FORMAT}, defaults: { format: :json }
|
||||
get "users/:username/emails" => "users#check_emails", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
get "users/:username/preferences" => "users#preferences", constraints: {username: USERNAME_ROUTE_FORMAT}, as: :email_preferences
|
||||
get "users/:username/preferences/email" => "users_email#index", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
|
|
|
@ -4,14 +4,6 @@ describe "Groups" do
|
|||
let(:user) { Fabricate(:user) }
|
||||
let(:group) { Fabricate(:group, users: [user]) }
|
||||
|
||||
def sign_in(user)
|
||||
password = 'somecomplicatedpassword'
|
||||
user.update!(password: password)
|
||||
Fabricate(:email_token, confirmed: true, user: user)
|
||||
post "/session.json", { login: user.username, password: password }
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
describe 'viewing groups' do
|
||||
it 'should return the right response' do
|
||||
group.update_attributes!(visible: true)
|
||||
|
|
31
spec/integration/users_spec.rb
Normal file
31
spec/integration/users_spec.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "Users" do
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
||||
describe "updating a user" do
|
||||
before do
|
||||
sign_in(user)
|
||||
end
|
||||
|
||||
it "should be able to update a user" do
|
||||
put "/users/#{user.username}.json", { name: 'test.test' }
|
||||
|
||||
expect(response).to be_success
|
||||
expect(user.reload.name).to eq('test.test')
|
||||
end
|
||||
|
||||
describe 'when username contains a period' do
|
||||
before do
|
||||
user.update!(username: 'test.test')
|
||||
end
|
||||
|
||||
it "should be able to update a user" do
|
||||
put "/users/#{user.username}.json", { name: 'testing123' }
|
||||
|
||||
expect(response).to be_success
|
||||
expect(user.reload.name).to eq('testing123')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -43,6 +43,7 @@ Spork.prefork do
|
|||
config.include Helpers
|
||||
config.include MessageBus
|
||||
config.include RSpecHtmlMatchers
|
||||
config.include IntegrationHelpers, type: :request
|
||||
config.mock_framework = :mocha
|
||||
config.order = 'random'
|
||||
config.infer_spec_type_from_file_location!
|
||||
|
|
9
spec/support/integration_helpers.rb
Normal file
9
spec/support/integration_helpers.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
module IntegrationHelpers
|
||||
def sign_in(user)
|
||||
password = 'somecomplicatedpassword'
|
||||
user.update!(password: password)
|
||||
Fabricate(:email_token, confirmed: true, user: user)
|
||||
post "/session.json", { login: user.username, password: password }
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user