|
|
|
@ -39,33 +39,30 @@ class IssuesHelperTest < HelperTestCase |
|
|
|
|
@request ||= ActionController::TestRequest.new |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
# This is probably needed in this test only anymore |
|
|
|
|
def show_detail(journal, detail, html = true) |
|
|
|
|
journal.render_detail(detail, html) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
# TODO: Move test code to Journal class |
|
|
|
|
context "IssuesHelper#show_detail" do |
|
|
|
|
context "with no_html" do |
|
|
|
|
should 'show a changing attribute' do |
|
|
|
|
@journal = IssueJournal.generate!(:changes => {"done_ratio" => [40, 100]}, :journaled => Issue.last) |
|
|
|
|
assert_equal "% Done changed from 40 to 100", show_detail(@journal, @journal.details.to_a.first, true) |
|
|
|
|
assert_equal "% Done changed from 40 to 100", @journal.render_detail(@journal.details.to_a.first, true) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
should 'show a new attribute' do |
|
|
|
|
@journal = IssueJournal.generate!(:changes => {"done_ratio" => [nil, 100]}, :journaled => Issue.last) |
|
|
|
|
assert_equal "% Done set to 100", show_detail(@journal, @journal.details.to_a.first, true) |
|
|
|
|
assert_equal "% Done set to 100", @journal.render_detail(@journal.details.to_a.first, true) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
should 'show a deleted attribute' do |
|
|
|
|
@journal = IssueJournal.generate!(:changes => {"done_ratio" => [50, nil]}, :journaled => Issue.last) |
|
|
|
|
assert_equal "% Done deleted (50)", show_detail(@journal, @journal.details.to_a.first, true) |
|
|
|
|
assert_equal "% Done deleted (50)", @journal.render_detail(@journal.details.to_a.first, true) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "with html" do |
|
|
|
|
should 'show a changing attribute with HTML highlights' do |
|
|
|
|
@journal = IssueJournal.generate!(:changes => {"done_ratio" => [40, 100]}, :journaled => Issue.last) |
|
|
|
|
@response.body = show_detail(@journal, @journal.details.to_a.first, false) |
|
|
|
|
@response.body = @journal.render_detail(@journal.details.to_a.first, false) |
|
|
|
|
|
|
|
|
|
assert_select 'strong', :text => '% Done' |
|
|
|
|
assert_select 'i', :text => '40' |
|
|
|
@ -74,7 +71,7 @@ class IssuesHelperTest < HelperTestCase |
|
|
|
|
|
|
|
|
|
should 'show a new attribute with HTML highlights' do |
|
|
|
|
@journal = IssueJournal.generate!(:changes => {"done_ratio" => [nil, 100]}, :journaled => Issue.last) |
|
|
|
|
@response.body = show_detail(@journal, @journal.details.to_a.first, false) |
|
|
|
|
@response.body = @journal.render_detail(@journal.details.to_a.first, false) |
|
|
|
|
|
|
|
|
|
assert_select 'strong', :text => '% Done' |
|
|
|
|
assert_select 'i', :text => '100' |
|
|
|
@ -82,7 +79,7 @@ class IssuesHelperTest < HelperTestCase |
|
|
|
|
|
|
|
|
|
should 'show a deleted attribute with HTML highlights' do |
|
|
|
|
@journal = IssueJournal.generate!(:changes => {"done_ratio" => [50, nil]}, :journaled => Issue.last) |
|
|
|
|
@response.body = show_detail(@journal, @journal.details.to_a.first, false) |
|
|
|
|
@response.body = @journal.render_detail(@journal.details.to_a.first, false) |
|
|
|
|
|
|
|
|
|
assert_select 'strong', :text => '% Done' |
|
|
|
|
assert_select 'strike' do |
|
|
|
@ -94,24 +91,24 @@ class IssuesHelperTest < HelperTestCase |
|
|
|
|
context "with a start_date attribute" do |
|
|
|
|
should "format the current date" do |
|
|
|
|
@journal = IssueJournal.generate!(:changes => {"start_date" => ['2010-01-01', '2010-01-31']}, :journaled => Issue.last) |
|
|
|
|
assert_match "01/31/2010", show_detail(@journal, @journal.details.to_a.first, true) |
|
|
|
|
assert_match "01/31/2010", @journal.render_detail(@journal.details.to_a.first, true) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
should "format the old date" do |
|
|
|
|
@journal = IssueJournal.generate!(:changes => {"start_date" => ['2010-01-01', '2010-01-31']}, :journaled => Issue.last) |
|
|
|
|
assert_match "01/01/2010", show_detail(@journal, @journal.details.to_a.first, true) |
|
|
|
|
assert_match "01/01/2010", @journal.render_detail(@journal.details.to_a.first, true) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "with a due_date attribute" do |
|
|
|
|
should "format the current date" do |
|
|
|
|
@journal = IssueJournal.generate!(:changes => {"due_date" => ['2010-01-01', '2010-01-31']}, :journaled => Issue.last) |
|
|
|
|
assert_match "01/31/2010", show_detail(@journal, @journal.details.to_a.first, true) |
|
|
|
|
assert_match "01/31/2010", @journal.render_detail(@journal.details.to_a.first, true) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
should "format the old date" do |
|
|
|
|
@journal = IssueJournal.generate!(:changes => {"due_date" => ['2010-01-01', '2010-01-31']}, :journaled => Issue.last) |
|
|
|
|
assert_match "01/01/2010", show_detail(@journal, @journal.details.to_a.first, true) |
|
|
|
|
assert_match "01/01/2010", @journal.render_detail(@journal.details.to_a.first, true) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|