* removed from cost_object as acts_as_journalized does not play well with subclasses * create migration for recreating initial journalspull/6827/head
parent
cdb2e8e54d
commit
5027a42a8d
@ -0,0 +1,34 @@ |
||||
class CreateInitialVariableCostObjectJournals < ActiveRecord::Migration |
||||
def self.up |
||||
[VariableCostObject].each do |p| |
||||
say_with_time("Building initial journals for #{p.class_name}") do |
||||
|
||||
# avoid touching the journaled object on journal creation |
||||
p.journal_class.class_exec { |
||||
def touch_journaled_after_creation |
||||
end |
||||
} |
||||
|
||||
# Create initial journals |
||||
p.find(:all).each do |o| |
||||
# Using rescue and save! here because either the Journal or the |
||||
# touched record could fail. This will catch either error and continue |
||||
begin |
||||
new_journal = o.recreate_initial_journal! |
||||
rescue ActiveRecord::RecordInvalid => ex |
||||
if new_journal.errors.count == 1 && new_journal.errors.first[0] == "version" |
||||
# Skip, only error was from creating the initial journal for a record that already had one. |
||||
else |
||||
puts "ERROR: errors creating the initial journal for #{o.class.to_s}##{o.id.to_s}:" |
||||
puts " #{ex.message}" |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
|
||||
def self.down |
||||
VariableCostObjectJournal.destroy_all |
||||
end |
||||
end |
@ -0,0 +1,29 @@ |
||||
Feature: Cost Object activities |
||||
|
||||
Background: |
||||
Given there is a standard cost control project named "project1" |
||||
And I am admin |
||||
|
||||
Scenario: cost object is a selectable activity type |
||||
When I go to the activity page of the project "project1" |
||||
Then I should see "Budgets" within "#sidebar" |
||||
|
||||
Scenario: Generating a cost object creates an activity |
||||
Given there is a variable cost object with the following: |
||||
| project | project1 | |
||||
| subject | Cost Object Subject | |
||||
| created_on | Time.now - 1.day | |
||||
When I go to the activity page of the project "project1" |
||||
Then I should see "Cost Object Subject" |
||||
|
||||
Scenario: Updating a cost object creates an activity |
||||
Given there is a variable cost object with the following: |
||||
| project | project1 | |
||||
| subject | cost_object1 | |
||||
| created_on | Time.now - 40.days | |
||||
And I update the variable cost object "cost_object1" with the following: |
||||
| subject | cost_object1_new_title | |
||||
When I go to the activity page of the project "project1" |
||||
Then I should see "cost_object1_new_title" |
||||
|
||||
|
@ -0,0 +1,3 @@ |
||||
Factory.define :variable_cost_object do |co| |
||||
|
||||
end |
Loading…
Reference in new issue