[#4182] Refactor duplicated test setup to helper.

This commit is contained in:
Eric Davis
2010-07-07 13:26:50 -07:00
parent b8edb5b4fc
commit 9da37a6cfd
2 changed files with 30 additions and 45 deletions
@@ -9,6 +9,8 @@ class OverheadPluginIntegrationTest < ActionController::IntegrationTest
User.add_to_project(@manager, @project, @role)
@fixed_deliverable = FixedDeliverable.generate!(:contract => @contract, :manager => @manager, :title => 'The Title')
@hourly_deliverable = HourlyDeliverable.generate!(:contract => @contract, :manager => @manager, :title => 'An Hourly')
configure_overhead_plugin
end
context "Patches to Deliverable" do
@@ -26,28 +28,6 @@ class OverheadPluginIntegrationTest < ActionController::IntegrationTest
end
should "return the total cost for all of the time on the issues for billable activities" do
@custom_field = TimeEntryActivityCustomField.generate!
Setting['plugin_redmine_overhead'] = {
'custom_field' => @custom_field.id.to_s,
'billable_value' => "true",
'overhead_value' => "false"
}
@billable_activity = TimeEntryActivity.generate!.reload
@billable_activity.custom_field_values = {
@custom_field.id => 'true'
}
assert @billable_activity.save
assert @billable_activity.billable?
@non_billable_activity = TimeEntryActivity.generate!.reload
@non_billable_activity.custom_field_values = {
@custom_field.id => 'false'
}
assert @non_billable_activity.save
assert !@non_billable_activity.billable?
@issue1 = Issue.generate_for_project!(@project)
@time_entry1 = TimeEntry.generate!(:issue => @issue1,
@@ -87,29 +67,6 @@ class OverheadPluginIntegrationTest < ActionController::IntegrationTest
end
should "return the total cost for all of the time on the issues for billable activities" do
@custom_field = TimeEntryActivityCustomField.generate!
Setting['plugin_redmine_overhead'] = {
'custom_field' => @custom_field.id.to_s,
'billable_value' => "true",
'overhead_value' => "false"
}
@billable_activity = TimeEntryActivity.generate!.reload
@billable_activity.custom_field_values = {
@custom_field.id => 'true'
}
assert @billable_activity.save
assert @billable_activity.billable?
@non_billable_activity = TimeEntryActivity.generate!.reload
@non_billable_activity.custom_field_values = {
@custom_field.id => 'false'
}
assert @non_billable_activity.save
assert !@non_billable_activity.billable?
@issue1 = Issue.generate_for_project!(@project)
@time_entry1 = TimeEntry.generate!(:issue => @issue1,
:project => @project,
+28
View File
@@ -81,3 +81,31 @@ end
class ActionController::IntegrationTest
include IntegrationTestHelper
end
class ActiveSupport::TestCase
def configure_overhead_plugin
@custom_field = TimeEntryActivityCustomField.generate!
Setting['plugin_redmine_overhead'] = {
'custom_field' => @custom_field.id.to_s,
'billable_value' => "true",
'overhead_value' => "false"
}
@billable_activity = TimeEntryActivity.generate!.reload
@billable_activity.custom_field_values = {
@custom_field.id => 'true'
}
assert @billable_activity.save
assert @billable_activity.billable?
@non_billable_activity = TimeEntryActivity.generate!.reload
@non_billable_activity.custom_field_values = {
@custom_field.id => 'false'
}
assert @non_billable_activity.save
assert !@non_billable_activity.billable?
end
end