Skip to content

Commit

Permalink
Completed pending specs; Modified Cohort title
Browse files Browse the repository at this point in the history
  • Loading branch information
soyapi committed Jul 28, 2008
1 parent 370665e commit f7304eb
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 17 deletions.
6 changes: 0 additions & 6 deletions app/models/location.rb
Expand Up @@ -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'

Expand Down
2 changes: 1 addition & 1 deletion app/models/patient_identifier.rb
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion app/views/reports/cohort.rhtml
@@ -1,7 +1,9 @@
<%= render :partial => 'header' %>
<% if params["id"] == "Cumulative" %>
<h1 id="cohort_title"><%= "Cumulative cohort analysis<br/> #{@quarter_start.strftime("%d %b %Y")} to #{@quarter_end.strftime("%d %b %Y")} for #{Location.current_location.name}"%></h1>
<h1 id="cohort_title">
<%= Location.current_location.name %>
<%= "Cumulative cohort analysis<br/> #{@quarter_start.strftime("%d %b %Y")} to #{@quarter_end.strftime("%d %b %Y")}"%></h1>
<% else %>
<h1 id="cohort_title"><%= "Quarterly cohort analysis<br/> #{@quarter_start.strftime("%d %b %Y")} to #{@quarter_end.strftime("%d %b %Y")} "%></h1>
<% end %>
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/locations.csv
@@ -0,0 +1 @@
999,XYZ Clinic,2,XYZ,3,A,Clinic,Rural,Aaaa
9 changes: 8 additions & 1 deletion spec/models/field_type_spec.rb
Expand Up @@ -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)
Expand Down
11 changes: 5 additions & 6 deletions spec/models/location_spec.rb
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion spec/models/report_spec.rb
Expand Up @@ -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}
Expand Down
6 changes: 5 additions & 1 deletion spec/models/user_spec.rb
Expand Up @@ -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)
Expand Down

0 comments on commit f7304eb

Please sign in to comment.