Skip to content

Commit

Permalink
[api] also fix the comments in the history
Browse files Browse the repository at this point in the history
Same bug with xmlhash < 1.3
  • Loading branch information
coolo committed Dec 13, 2012
1 parent 07a59e9 commit b2cd6af
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/api/app/models/bs_request_history.rb
Expand Up @@ -5,6 +5,10 @@ class BsRequestHistory < ActiveRecord::Base
validates_inclusion_of :state, :in => VALID_REQUEST_STATES
validates :commenter, :presence => true

def state
read_attribute(:state).to_sym
end

def self.new_from_xml_hash(hash)
h = BsRequestHistory.new
h.comment = hash.delete("comment")
Expand Down
14 changes: 14 additions & 0 deletions src/api/db/migrate/20121213144129_fix_empty_comments2.rb
@@ -0,0 +1,14 @@
class FixEmptyComments2 < ActiveRecord::Migration
def up
BsRequestHistory.all.each do |r|
next if r.comment.blank?
if r.comment.strip == '--- !ruby/hash:Xmlhash::XMLHash {}'
r.comment = nil
r.save
end
end
end

def down
end
end
2 changes: 2 additions & 0 deletions src/api/db/structure.sql
Expand Up @@ -1009,6 +1009,8 @@ INSERT INTO schema_migrations (version) VALUES ('20121130143300');

INSERT INTO schema_migrations (version) VALUES ('20121213140751');

INSERT INTO schema_migrations (version) VALUES ('20121213144129');

INSERT INTO schema_migrations (version) VALUES ('21');

INSERT INTO schema_migrations (version) VALUES ('22');
Expand Down

0 comments on commit b2cd6af

Please sign in to comment.