refactors user's registration
Simplifies process and fields: * In: username * Out: first_name, last_name, phone, nickname, use_nickname? Closes #213
This commit is contained in:
@@ -30,6 +30,12 @@ describe User do
|
||||
expect(subject).to be_valid
|
||||
end
|
||||
|
||||
describe "#name" do
|
||||
it "is the username when the user is not an organization" do
|
||||
expect(subject.name).to eq(subject.username)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'preferences' do
|
||||
describe 'email_on_debate_comment' do
|
||||
it 'should be false by default' do
|
||||
@@ -44,45 +50,6 @@ describe User do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'use_nickname' do
|
||||
describe 'when true' do
|
||||
before { subject.use_nickname = true }
|
||||
|
||||
it "activates the validation of nickname" do
|
||||
subject.nickname = nil
|
||||
expect(subject).to_not be_valid
|
||||
|
||||
subject.nickname = "dredd"
|
||||
expect(subject).to be_valid
|
||||
end
|
||||
|
||||
it "calculates the name using the nickname" do
|
||||
subject.nickname = "dredd"
|
||||
expect(subject.name).to eq("dredd")
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when false' do
|
||||
before { subject.use_nickname = false }
|
||||
|
||||
it "activates the validation of first_name and last_name" do
|
||||
subject.first_name = nil
|
||||
subject.last_name = nil
|
||||
expect(subject).to_not be_valid
|
||||
|
||||
subject.first_name = "Joseph"
|
||||
subject.last_name = "Dredd"
|
||||
expect(subject).to be_valid
|
||||
end
|
||||
|
||||
it "calculates the name using first_name and last_name" do
|
||||
subject.first_name = "Joseph"
|
||||
subject.last_name = "Dredd"
|
||||
expect(subject.name).to eq("Joseph Dredd")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "administrator?" do
|
||||
it "is false when the user is not an admin" do
|
||||
expect(subject.administrator?).to be false
|
||||
@@ -152,9 +119,8 @@ describe User do
|
||||
expect(subject.organization.name).to eq('org')
|
||||
end
|
||||
|
||||
it "deactivates the validation of first_name and last_name, and activates the validation of organization" do
|
||||
subject.first_name = nil
|
||||
subject.last_name = nil
|
||||
it "deactivates the validation of username, and activates the validation of organization" do
|
||||
subject.username = nil
|
||||
expect(subject).to be_valid
|
||||
|
||||
subject.organization.name= nil
|
||||
|
||||
Reference in New Issue
Block a user