Skip to content
This repository was archived by the owner on May 25, 2022. It is now read-only.

Commit

Permalink
Don't create unique id if it already exists. Going forward BB app wou…
Browse files Browse the repository at this point in the history
…ld be creating a unique id when ever the child is created. so we need not recreate the id in the rails app
  • Loading branch information
kishoreyekkanti authored and Ashok committed Sep 12, 2012
1 parent 2438b41 commit 825a6bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/child.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def self.flagged

def self.new_with_user_name(user_name, fields = {})
child = new(fields)
child.create_unique_id user_name
child.create_unique_id user_name unless child['unique_identifier']
child.set_creation_fields_for user_name
child
end
Expand Down
5 changes: 5 additions & 0 deletions spec/models/child_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@
child['unique_identifier'].should == "jdoelon12345"
end

it "should not create a unique id if already exists" do
child = Child.new_with_user_name('jdoe', 'last_known_location' => 'London', 'unique_identifier' => 'rapidftrxxx5bcde')
child['unique_identifier'].should == "rapidftrxxx5bcde"
end

it "should create a created_by field with the user name" do
child = Child.new_with_user_name('jdoe', 'some_field' => 'some_value')
child['created_by'].should == 'jdoe'
Expand Down

0 comments on commit 825a6bf

Please sign in to comment.