Skip to content

Commit

Permalink
Merge pull request leovitch#15 from tatsus/patch
Browse files Browse the repository at this point in the history
Patch to fix import problems
  • Loading branch information
zh committed Oct 28, 2013
2 parents c23171f + 30a7041 commit af7c8c5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
10 changes: 4 additions & 6 deletions app/controllers/importer_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def match
@samples = []

CSV.new(iip.csv_data, {:headers=>true,
:converters => :all,
:encoding=>iip.encoding,
:quote_char=>iip.quote_char,
:col_sep=>iip.col_sep}).each do |row|
Expand Down Expand Up @@ -226,7 +225,6 @@ def result
end

CSV.new(iip.csv_data, {:headers=>true,
:converters => :all,
:encoding=>iip.encoding,
:quote_char=>iip.quote_char,
:col_sep=>iip.col_sep}).each do |row|
Expand Down Expand Up @@ -255,7 +253,7 @@ def result
category.save
end
assigned_to = row[attrs_map["assigned_to"]] != nil ? user_for_login!(row[attrs_map["assigned_to"]]) : nil
fixed_version_name = row[attrs_map["fixed_version"]]
fixed_version_name = row[attrs_map["fixed_version"]].blank? ? nil : row[attrs_map["fixed_version"]]
fixed_version_id = fixed_version_name ? version_id_for_name!(project,fixed_version_name,add_versions) : nil
watchers = row[attrs_map["watchers"]]
# new issue or find exists one
Expand Down Expand Up @@ -343,8 +341,8 @@ def result
# optional attributes
issue.description = row[attrs_map["description"]] || issue.description
issue.category_id = category != nil ? category.id : issue.category_id
issue.start_date = row[attrs_map["start_date"]] || issue.start_date
issue.due_date = row[attrs_map["due_date"]] || issue.due_date
issue.start_date = row[attrs_map["start_date"]].blank? ? nil : Date.parse(row[attrs_map["start_date"]])
issue.due_date = row[attrs_map["due_date"]].blank? ? nil : Date.parse(row[attrs_map["due_date"]])
issue.assigned_to_id = assigned_to != nil ? assigned_to.id : issue.assigned_to_id
issue.fixed_version_id = fixed_version_id != nil ? fixed_version_id : issue.fixed_version_id
issue.done_ratio = row[attrs_map["done_ratio"]] || issue.done_ratio
Expand Down Expand Up @@ -428,7 +426,7 @@ def result
@failed_issues[@failed_count] = row
flash_message(:warning, "The following data-validation errors occurred on issue #{@failed_count} in the list below")
issue.errors.each do |attr, error_message|
flash_message(:warning, "  "+error_message)
flash_message(:warning, "  #{error_message}")
end
else
if unique_field
Expand Down
3 changes: 3 additions & 0 deletions test/samples/AllStandardBlankFields.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"Subject","Description","Assigned To","Fixed version","Author","Category","Priority","Tracker","Status","Start date","Due date","Done Ratio","Estimated hours","Watchers"
"A blank task","","","","","","","","",,,,,""
"A blank task",,,,"",,,,,,,,,
2 changes: 2 additions & 0 deletions test/samples/NumberAsStringFields.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"Subject","Description","Assigned To","Fixed version","Author","Category","Priority","Tracker","Status","Start date","Due date","Done Ratio","Estimated hours","Watchers"
"A number task","","100_001","9.99","100_001","","","","",,,,,""

0 comments on commit af7c8c5

Please sign in to comment.