Skip to content

Instantly share code, notes, and snippets.

@camallen
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save camallen/30eb9c759c65c4644104 to your computer and use it in GitHub Desktop.

Select an option

Save camallen/30eb9c759c65c4644104 to your computer and use it in GitHub Desktop.
Quick spec to show the UriName model doesn't handle case-insensitive duplicate names
describe '#login' do
it 'should validate presence' do
expect{ User.create!(name: 't', password: 'password1', email: 'test@example.com') }.to raise_error
end
it 'should validate uniqueness' do
expect{ User.create!(name: 't', login: 't', password: 'password1', email: 'test@example.com') }.to_not raise_error
expect{ User.create!(name: 't', login: 't', password: 'password1', email: 'test2@example.com') }.to raise_error
expect{ User.create!(name: 'T', login: 'T', password: 'password1', email: 'test3@example.com') }.to raise_error
end
context "when a userGroup with the same login/name but different case already exists" do
let!(:change_user_name) { user.attributes={ "login" => "zoo", "name" => "zooniverse"} }
let!(:user_group) { create(:user_group, name: "ZooNiVeRsE", display_name: "zoo") }
it "should not be valid" do
expect(user.valid?).to be false
end
it "should an error message on the name field"do
user.valid?
expect(user.errors[:name]).to include("some error re the uri_name login/name field being already taken")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment