Skip to content

Commit

Permalink
Cope with empty description field
Browse files Browse the repository at this point in the history
Edit some fixture files
  • Loading branch information
chrislo committed Feb 9, 2010
1 parent e9aa1d2 commit cf852ec
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 9 deletions.
2 changes: 1 addition & 1 deletion jira.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gem::Specification.new do |s|
s.email = %q{[email protected]}
s.executables = ["jira"]
s.extra_rdoc_files = ["README.rdoc"]
s.files = ["jira.gemspec", "LICENSE", "README.rdoc", "bin/jira", "spec/fixtures", "spec/fixtures/issues.xml", "spec/fixtures/TST-14301.xml", "spec/jira", "spec/jira/hash_spec.rb", "spec/jira/issue_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "lib/jira", "lib/jira/cli.rb", "lib/jira/ext", "lib/jira/ext/hash.rb", "lib/jira/issue.rb", "lib/jira.rb"]
s.files = ["jira.gemspec", "LICENSE", "README.rdoc", "bin/jira", "spec/fixtures", "spec/fixtures/issues.xml", "spec/fixtures/TST-104.xml", "spec/fixtures/TST-14301.xml", "spec/jira", "spec/jira/hash_spec.rb", "spec/jira/issue_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "lib/jira", "lib/jira/cli.rb", "lib/jira/ext", "lib/jira/ext/hash.rb", "lib/jira/issue.rb", "lib/jira.rb"]
s.homepage = %q{http://github.com/chrislo/jira}
s.rdoc_options = ["--main", "README.rdoc"]
s.require_paths = ["lib"]
Expand Down
13 changes: 11 additions & 2 deletions lib/jira/issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ def find_by_ticket_number(ticket_number)
res = @resource["si/jira.issueviews:issue-xml/#{ticket_number}/#{ticket_number}.xml"].get
doc = XmlSimple.xml_in res.to_s
item = doc['channel'].first['item'].first

OpenStruct.new(:title => item['title'].first,
:description => Sanitize.clean(item['description'].first),
:description => sanitize(item['description'].first),
:assignee => item['assignee'].first['username'],
:resolution => item['resolution'].first['content'])
end
Expand All @@ -37,5 +36,15 @@ def list_all_open_assigned_issues
issues = find_all_open_assigned_issues
issues.map{|i| "* #{i.title}"}.join("\n")
end

private
def sanitize(text)
if text.is_a? Hash
""
else
Sanitize.clean(text)
end
end

end
end
99 changes: 99 additions & 0 deletions spec/fixtures/TST-104.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<!-- RSS generated by JIRA (Enterprise Edition, Version: 3.13-#330) at Tue Feb 09 10:49:17 GMT 2010 -->
<rss version="0.92" >
<channel>
<title JIRA</title>
<link>https://jira.co.uk:443</link>
<description>This file is an XML representation of an issue</description>
<language>en-gb</language> <build-info>
<version>3.13</version>
<build-number>330</build-number>
<build-date>27-08-2008</build-date>
<edition>Enterprise</edition>
</build-info>

<item>
<title>some title</title>
<link>https://jira.co.uk:443/browse/TST-104</link>

<description></description>
<environment></environment>
<key id="62888">PIT-104</key>
<summary>summary</summary>
<type id="10" iconUrl="https://jira.co.uk:443/images/icons/issue_subtask.gif">Sub-task</type>
<priority id="5" iconUrl="https://jira.co.uk:443https://confluence.co.uk/download/attachments/6162113/error.png">Unknown</priority>
<status id="3" iconUrl="https://jira.co.uk:443/images/icons/status_inprogress.gif">In Progress</status>
<resolution id="-1">Unresolved</resolution>


<assignee username="chris.lowis">Chris Lowis</assignee>

<reporter username="chris.lowis">Chris Lowis</reporter>

<created>Thu, 17 Dec 2009 15:55:16 +0000 (GMT)</created>
<updated>Tue, 9 Feb 2010 10:14:05 +0000 (GMT)</updated>


<fixVersion>TST 2.13 Sprint 3 </fixVersion>

<component>TST</component>

<due></due>

<votes>0</votes>



<comments>
<comment id="93087" author="chris.lowis" created="Tue, 9 Feb 2010 10:14:05 +0000 (GMT)" >This has been done.
</comment>
</comments>

<issuelinks>
<issuelinktype id="10001">
<name>Depend</name>
<inwardlinks description="is dependent on">
<issuelink>
<issuekey id="63058">TST-7471</issuekey>
</issuelink>
</inwardlinks>
</issuelinktype>
</issuelinks>
<attachments>
</attachments>

<subtasks>
</subtasks>

<customfields>
<customfield id="customfield_10061" key="com.pyxis.greenhopper.jira:greenhopper-ranking">
<customfieldname>Backlog Priority</customfieldname>
<customfieldvalues>
<customfieldvalue>3.4E8</customfieldvalue>
</customfieldvalues>
</customfield>
<customfield id="customfield_10272" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
<customfieldname>Change Type</customfieldname>
<customfieldvalues>
<customfieldvalue><![CDATA[Managed]]></customfieldvalue>

</customfieldvalues>
</customfield>
<customfield id="customfield_10310" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
<customfieldname>Group assignee</customfieldname>
<customfieldvalues>
<customfieldvalue><![CDATA[Not assigned]]></customfieldvalue>

</customfieldvalues>
</customfield>
<customfield id="customfield_10297" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
<customfieldname>Tech kick-off</customfieldname>
<customfieldvalues>
<customfieldvalue><![CDATA[No]]></customfieldvalue>

</customfieldvalues>
</customfield>
</customfields>

</item>
</channel>
</rss>
12 changes: 6 additions & 6 deletions spec/fixtures/TST-14301.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- RSS generated by JIRA (Enterprise Edition, Version: 3.13-#330) at Thu Jan 28 15:16:35 GMT 2010 -->
<rss version="0.92" >
<channel>
<title>BBC JIRA</title>
<link>https://jira.dev.bbc.co.uk:443</link>
<title>JIRA</title>
<link>https://jira.co.uk:443</link>
<description>This file is an XML representation of an issue</description>
<language>en-gb</language> <build-info>
<version>3.13</version>
Expand All @@ -13,16 +13,16 @@

<item>
<title>[TST-14301] Test</title>
<link>https://jira.dev.bbc.co.uk:443/browse/TST-14301</link>
<link>https://jira.co.uk:443/browse/TST-14301</link>

<description>A test ticket</description>
<environment></environment>
<key id="48203">TST-14301</key>
<summary>Test</summary>
<type id="18" iconUrl="https://jira.dev.bbc.co.uk:443https://confluence.dev.bbc.co.uk/download/attachments/6162113/application_go.png">Change</type>
<type id="18" iconUrl="https://jira.co.uk:443https://confluence.co.uk/download/attachments/6162113/application_go.png">Change</type>

<priority id="5" iconUrl="https://jira.dev.bbc.co.uk:443https://confluence.dev.bbc.co.uk/download/attachments/6162113/error.png">Unknown</priority>
<status id="1" iconUrl="https://jira.dev.bbc.co.uk:443/images/icons/status_open.gif">Open</status>
<priority id="5" iconUrl="https://jira.co.uk:443https://confluence.co.uk/download/attachments/6162113/error.png">Unknown</priority>
<status id="1" iconUrl="https://jira.co.uk:443/images/icons/status_open.gif">Open</status>
<resolution id="-1">Unresolved</resolution>


Expand Down
11 changes: 11 additions & 0 deletions spec/jira/issue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ module Jira
:body => File.read(File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures', 'TST-14301.xml'))))
end

describe "empty fields" do
it "should cope with an empty description field" do
FakeWeb.register_uri(:get,
"#{@options[:jira_base]}/si/jira.issueviews:issue-xml/TST-104/TST-104.xml",
:body => File.read(File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures', 'TST-104.xml'))))
ticket = Jira::Issue.new(@options).find_by_ticket_number('TST-104')
ticket.description.should == ""
end
end


describe "sanitize the description" do
it "should sanitize the description of the issue" do
Sanitize.should_receive(:clean).with("A test ticket")
Expand Down

0 comments on commit cf852ec

Please sign in to comment.