2016-12-16 11:21:28 -05:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe "Users" do
|
|
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
|
2016-12-16 13:26:22 -05:00
|
|
|
describe "viewing a user" do
|
|
|
|
|
|
|
|
it "should be able to view a user" do
|
2017-03-28 14:27:54 -04:00
|
|
|
get "/u/#{user.username}"
|
2016-12-16 13:26:22 -05:00
|
|
|
|
|
|
|
expect(response).to be_success
|
|
|
|
expect(response.body).to include(user.username)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'when username contains a period' do
|
|
|
|
before do
|
|
|
|
user.update!(username: 'test.test')
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should be able to view a user" do
|
2017-03-28 14:27:54 -04:00
|
|
|
get "/u/#{user.username}"
|
2016-12-16 13:26:22 -05:00
|
|
|
|
|
|
|
expect(response).to be_success
|
|
|
|
expect(response.body).to include(user.username)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-12-16 11:21:28 -05:00
|
|
|
describe "updating a user" do
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should be able to update a user" do
|
2017-07-27 21:20:09 -04:00
|
|
|
put "/u/#{user.username}.json", name: 'test.test'
|
2016-12-16 11:21:28 -05:00
|
|
|
|
|
|
|
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
|
2017-07-27 21:20:09 -04:00
|
|
|
put "/u/#{user.username}.json", name: 'testing123'
|
2016-12-16 11:21:28 -05:00
|
|
|
|
|
|
|
expect(response).to be_success
|
|
|
|
expect(user.reload.name).to eq('testing123')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|