fix creation of journals in order to fix some tests

pull/1186/head
Martin Linkhorst 12 years ago
parent 711f4e63ee
commit 43b0bc2e46
  1. 18
      test/test_helper.rb
  2. 50
      test/unit/helpers/issues_helper_test.rb

@ -204,17 +204,19 @@ class ActiveSupport::TestCase
end
should "use the new value's name" do
@detail = IssueJournal.generate(:version => 1, :journaled => Issue.last)
@detail.update_attribute(:changed_data, {prop_key => [@old_value.id, @new_value.id]}.to_yaml)
assert_match @new_value.class.find(@new_value.id).name, @detail.render_detail(prop_key, true)
@journal = IssueJournal.create! do |j|
j.changed_data = {prop_key => [@old_value.id, @new_value.id]}
j.journaled = Issue.last
end
assert_match @new_value.class.find(@new_value.id).name, @journal.render_detail(prop_key, true)
end
should "use the old value's name" do
@detail = IssueJournal.generate(:version => 1, :journaled => Issue.last)
@detail.update_attribute(:changed_data, {prop_key => [@old_value.id, @new_value.id]}.to_yaml)
assert_match @old_value.class.find(@old_value.id).name, @detail.render_detail(prop_key, true)
@journal = IssueJournal.create! do |j|
j.changed_data = {prop_key => [@old_value.id, @new_value.id]}
j.journaled = Issue.last
end
assert_match @old_value.class.find(@old_value.id).name, @journal.render_detail(prop_key, true)
end
end
end

@ -45,24 +45,36 @@ class IssuesHelperTest < HelperTestCase
context "IssuesHelper#show_detail" do
context "with no_html" do
should 'show a changing attribute' do
@journal = IssueJournal.generate!(:changed_data => {"done_ratio" => [40, 100]}, :journaled => Issue.last)
@journal = IssueJournal.create! do |j|
j.changed_data = {"done_ratio" => [40, 100]}
j.journaled = Issue.last
end
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!(:changed_data => {"done_ratio" => [nil, 100]}, :journaled => Issue.last)
@journal = IssueJournal.create! do |j|
j.changed_data = {"done_ratio" => [nil, 100]}
j.journaled = Issue.last
end
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!(:changed_data => {"done_ratio" => [50, nil]}, :journaled => Issue.last)
@journal = IssueJournal.create! do |j|
j.changed_data = {"done_ratio" => [50, nil]}
j.journaled = Issue.last
end
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!(:changed_data => {"done_ratio" => [40, 100]}, :journaled => Issue.last)
@journal = IssueJournal.create! do |j|
j.changed_data = {"done_ratio" => [40, 100]}
j.journaled = Issue.last
end
@response.body = @journal.render_detail(@journal.details.to_a.first, false)
html_node = HTML::Document.new(@response.body)
@ -72,7 +84,10 @@ class IssuesHelperTest < HelperTestCase
end
should 'show a new attribute with HTML highlights' do
@journal = IssueJournal.generate!(:changed_data => {"done_ratio" => [nil, 100]}, :journaled => Issue.last)
@journal = IssueJournal.create! do |j|
j.changed_data = {"done_ratio" => [nil, 100]}
j.journaled = Issue.last
end
@response.body = @journal.render_detail(@journal.details.to_a.first, false)
html_node = HTML::Document.new(@response.body)
@ -81,7 +96,10 @@ class IssuesHelperTest < HelperTestCase
end
should 'show a deleted attribute with HTML highlights' do
@journal = IssueJournal.generate!(:changed_data => {"done_ratio" => [50, nil]}, :journaled => Issue.last)
@journal = IssueJournal.create! do |j|
j.changed_data = {"done_ratio" => [50, nil]}
j.journaled = Issue.last
end
@response.body = @journal.render_detail(@journal.details.to_a.first, false)
html_node = HTML::Document.new(@response.body)
@ -94,24 +112,36 @@ class IssuesHelperTest < HelperTestCase
context "with a start_date attribute" do
should "format the current date" do
@journal = IssueJournal.generate!(:changed_data => {"start_date" => ['2010-01-01', '2010-01-31']}, :journaled => Issue.last)
@journal = IssueJournal.create! do |j|
j.changed_data = {"start_date" => ['2010-01-01', '2010-01-31']}
j.journaled = Issue.last
end
assert_match "01/31/2010", @journal.render_detail(@journal.details.to_a.first, true)
end
should "format the old date" do
@journal = IssueJournal.generate!(:changed_data => {"start_date" => ['2010-01-01', '2010-01-31']}, :journaled => Issue.last)
@journal = IssueJournal.create! do |j|
j.changed_data = {"start_date" => ['2010-01-01', '2010-01-31']}
j.journaled = Issue.last
end
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!(:changed_data => {"due_date" => ['2010-01-01', '2010-01-31']}, :journaled => Issue.last)
@journal = IssueJournal.create! do |j|
j.changed_data = {"due_date" => ['2010-01-01', '2010-01-31']}
j.journaled = Issue.last
end
assert_match "01/31/2010", @journal.render_detail(@journal.details.to_a.first, true)
end
should "format the old date" do
@journal = IssueJournal.generate!(:changed_data => {"due_date" => ['2010-01-01', '2010-01-31']}, :journaled => Issue.last)
@journal = IssueJournal.create! do |j|
j.changed_data = {"due_date" => ['2010-01-01', '2010-01-31']}
j.journaled = Issue.last
end
assert_match "01/01/2010", @journal.render_detail(@journal.details.to_a.first, true)
end
end

Loading…
Cancel
Save