Skip to content

Commit

Permalink
Not set password when user exists. Add missing specs
Browse files Browse the repository at this point in the history
  • Loading branch information
taitus committed Jan 29, 2018
1 parent 31a0ba0 commit 9eab4d5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def self.create_from_uweb(role, data)
user.last_name = data["APELLIDO1_USUARIO"].strip
user.last_name += ' ' + data["APELLIDO2_USUARIO"].strip if data["APELLIDO2_USUARIO"].present?
user.email = data["MAIL"].blank? ? Faker::Internet.email : data["MAIL"]
user.password = SecureRandom.uuid
user.password = SecureRandom.uuid unless user.persisted?
user.role = role
user
end
Expand Down
14 changes: 12 additions & 2 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,22 @@

it "should have be valid when created from uweb data array" do
data = FactoryGirl.build(:uweb_user)

user = User.create_from_uweb(:user, data)
expect(user).to be_valid

expect { user.save }.to change { User.count }.from(1).to(2)
end

it "should have be valid when created from uweb data array and user exists by user_key" do
data = FactoryGirl.build(:uweb_user)
@user.update(user_key: data["CLAVE_IND"] )

user = User.create_from_uweb(:user, data)

expect { user.save }.not_to change { User.count }
end

it "should not be allowed assign holder more than once to user" do
end

end

0 comments on commit 9eab4d5

Please sign in to comment.