202 |
202 |
def test_create_with_initialized_journals_should_create_journals
|
203 |
203 |
from = Issue.find(1)
|
204 |
204 |
to = Issue.find(2)
|
205 |
|
from_journals = from.journals.size
|
206 |
|
to_journals = to.journals.size
|
207 |
205 |
relation = IssueRelation.new(:issue_from => from, :issue_to => to,
|
208 |
206 |
:relation_type => IssueRelation::TYPE_PRECEDES)
|
209 |
207 |
relation.init_journals User.find(1)
|
210 |
|
assert relation.save
|
211 |
|
from.reload
|
212 |
|
to.reload
|
213 |
|
relation.reload
|
214 |
|
assert_equal from.journals.size, (from_journals + 1)
|
215 |
|
assert_equal to.journals.size, (to_journals + 1)
|
216 |
|
assert_equal 'relation', from.journals.last.details.last.property
|
217 |
|
assert_equal 'precedes', from.journals.last.details.last.prop_key
|
218 |
|
assert_equal '2', from.journals.last.details.last.value
|
219 |
|
assert_nil from.journals.last.details.last.old_value
|
220 |
|
assert_equal 'relation', to.journals.last.details.last.property
|
221 |
|
assert_equal 'follows', to.journals.last.details.last.prop_key
|
222 |
|
assert_equal '1', to.journals.last.details.last.value
|
223 |
|
assert_nil to.journals.last.details.last.old_value
|
|
208 |
|
|
209 |
assert_difference(
|
|
210 |
->{ from.reload.journals.size } => +1,
|
|
211 |
->{ to.reload.journals.size } => +1
|
|
212 |
) do
|
|
213 |
assert relation.save
|
|
214 |
end
|
|
215 |
|
|
216 |
from.journals.last.details.then do |details|
|
|
217 |
assert details.exists?(property: 'relation', prop_key: 'precedes', value: '2')
|
|
218 |
end
|
|
219 |
|
|
220 |
to.journals.last.details.then do |details|
|
|
221 |
assert_equal 3, details.count
|
|
222 |
assert details.exists?(property: 'relation', prop_key: 'follows', value: '1', old_value: nil)
|
|
223 |
assert details.exists?(property: 'attr', prop_key: 'due_date')
|
|
224 |
assert details.exists?(property: 'attr', prop_key: 'start_date')
|
|
225 |
end
|
224 |
226 |
end
|
225 |
227 |
|
226 |
228 |
def test_destroy_with_initialized_journals_should_create_journals
|