diff --git a/app/models/location.rb b/app/models/location.rb
index 93717b51..007d6f21 100755
--- a/app/models/location.rb
+++ b/app/models/location.rb
@@ -47,12 +47,6 @@ def self.health_center
return Location.find(center_id)
end
- def health_center_room
- return nil if self.health_center == self
- return self.parent if self.name.match(/\d+\.\d+\./);
- return self
- end
-
def self.import_locations(name_of_csv_file)
require 'csv'
diff --git a/app/models/patient_identifier.rb b/app/models/patient_identifier.rb
index f30861de..2e820f16 100755
--- a/app/models/patient_identifier.rb
+++ b/app/models/patient_identifier.rb
@@ -112,7 +112,7 @@ def self.get_next_patient_identifier(identifier_type = "National id")
possible_identifiers_range = GlobalProperty.find_by_property("dormant_filing_number_range").property_value.to_i rescue 12000 if identifier_type =="Archived filing number"
possible_identifiers = Array.new(possible_identifiers_range){|i|prefix + (len_of_identifier + i +1).to_s}
- return ((possible_identifiers)-(current_identifiers)).first
+ return ((possible_identifiers)-(current_identifiers.compact.uniq)).first
end
def self.duplicates_by_type(identifier_type)
diff --git a/app/views/reports/cohort.rhtml b/app/views/reports/cohort.rhtml
index 1a743263..063a2a80 100755
--- a/app/views/reports/cohort.rhtml
+++ b/app/views/reports/cohort.rhtml
@@ -1,7 +1,9 @@
<%= render :partial => 'header' %>
<% if params["id"] == "Cumulative" %>
-
<%= "Cumulative cohort analysis
#{@quarter_start.strftime("%d %b %Y")} to #{@quarter_end.strftime("%d %b %Y")} for #{Location.current_location.name}"%>
+
+ <%= Location.current_location.name %>
+ <%= "Cumulative cohort analysis
#{@quarter_start.strftime("%d %b %Y")} to #{@quarter_end.strftime("%d %b %Y")}"%>
<% else %>
<%= "Quarterly cohort analysis
#{@quarter_start.strftime("%d %b %Y")} to #{@quarter_end.strftime("%d %b %Y")} "%>
<% end %>
diff --git a/spec/fixtures/locations.csv b/spec/fixtures/locations.csv
new file mode 100644
index 00000000..89a514cc
--- /dev/null
+++ b/spec/fixtures/locations.csv
@@ -0,0 +1 @@
+999,XYZ Clinic,2,XYZ,3,A,Clinic,Rural,Aaaa
diff --git a/spec/models/field_type_spec.rb b/spec/models/field_type_spec.rb
index d259a4e0..77456c10 100644
--- a/spec/models/field_type_spec.rb
+++ b/spec/models/field_type_spec.rb
@@ -19,7 +19,14 @@
field_type.should be_valid
end
- it "should find from ids"
+ it "should find from ids" do
+ FieldType.find_from_ids([11], nil).should == field_type(:field_type_00011)
+ field_type = FieldType.find(11)
+ field_type.id = 99
+ field_type.save
+ FieldType.find(11).id.should == 99 #use cached one
+ FieldType.find([11,10]).map(&:id).should == [10,11] # don't why it's still finding 11
+ end
it "should find by name" do
FieldType.find_by_name("select").should == field_type(:field_type_00002)
diff --git a/spec/models/location_spec.rb b/spec/models/location_spec.rb
index f7c73153..e18b4415 100644
--- a/spec/models/location_spec.rb
+++ b/spec/models/location_spec.rb
@@ -46,12 +46,11 @@
description.match(/arv code:(...)/)[0].split(":").last.should == "MPC"
end
- it "should display health center room"
-
- it "should import locations"
- #Location.import_locations("/var/www/bart/spec/location.csv")
- #Location.find(1208).name.should == "Bwaila"
- #end
+ it "should import locations" do
+ Location.destroy_all
+ Location.import_locations("/var/www/bart/spec/fixtures/locations.csv")
+ Location.find_by_name('XYZ Clinic').description.should == "Clinic , Rural"
+ end
it "should display health centers" do
Location.health_centers("house").last.name.should == "New Statehouse Dispensary"
diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb
index 8ec55670..cdd2e4f6 100644
--- a/spec/models/report_spec.rb
+++ b/spec/models/report_spec.rb
@@ -24,7 +24,9 @@
report.should be_valid
end
- it "should cache reports"
+ it "should cache reports" do
+ Report.methods.include?('cache').should be_true
+ end
it "should generate survival analysis hash" do
Report.survival_analysis_hash(Patient.find(:all), '2007-01-01'.to_date, '2007-03-31'.to_date, '2008-03-31'.to_date, 1).should == {"Defaulted"=>1, "End Date"=> '31 Mar 2007'.to_date, "Start Date"=> '01 Jan 2007'.to_date, "Title"=>"12 month survival: outcomes by end of March 2008", "On ART"=>3, "Transfer out"=>0, "Total"=>4, "Died"=>0, "ART Stop"=>0}
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 81cc2553..3add2d09 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -80,7 +80,11 @@
user.password.length.should == 40
end
- it "should reset password class variable after creating"
+ it "should reset password class variable after creating" do
+ user = User.new(:username => 'test', :password => 'tset')
+ user.save
+ user.instance_variable_get('@password').should be_nil
+ end
it "should authenticate given a userame and password" do
user = users(:mikmck)