DB: Integridade referencial
This commit is contained in:
4
test/fixtures/users.yml
vendored
4
test/fixtures/users.yml
vendored
@@ -21,7 +21,7 @@ bob:
|
||||
display_name: bob
|
||||
last_seen: <%= Time.now %>
|
||||
admin: true
|
||||
|
||||
secret: bob
|
||||
|
||||
existingbob:
|
||||
id: 1000002
|
||||
@@ -33,6 +33,7 @@ existingbob:
|
||||
display_name: existingbob
|
||||
last_seen: <%= Time.now %>
|
||||
admin: false
|
||||
secret: existingbob
|
||||
|
||||
longbob:
|
||||
id: 1000003
|
||||
@@ -44,3 +45,4 @@ longbob:
|
||||
display_name: longbob
|
||||
last_seen: <%= Time.now %>
|
||||
admin: false
|
||||
secret: longbob
|
||||
|
||||
@@ -17,36 +17,8 @@ class CourseTest < Test::Unit::TestCase
|
||||
|
||||
fixtures :courses
|
||||
|
||||
def test_orphaned_records
|
||||
# Escolhe um curso qualquer
|
||||
course = courses(:course_1)
|
||||
|
||||
# Cria alguns objetos associados ao curso
|
||||
attachment = Attachment.create(:file_name => 'test', :content_type => 'text/plain',
|
||||
:last_modified => Time.now, :description => 'test', :size => 1.megabyte,
|
||||
:course_id => course.id)
|
||||
|
||||
wiki_page = WikiPage.create(:title => 'teste', :course_id => course.id)
|
||||
|
||||
shoutbox_message = Message.create(:title => 'test', :body => 'test body',
|
||||
:timestamp => Time.now, :type => "CourseShoutboxMessage",
|
||||
:sender_id => 0, :receiver_id => course.id)
|
||||
|
||||
news_message = Message.create(:title => 'test', :body => 'test body',
|
||||
:timestamp => Time.now, :type => "News",
|
||||
:sender_id => 0, :receiver_id => course.id)
|
||||
|
||||
event = Event.create(:title => 'test', :time => Time.now,
|
||||
:created_by => 0, :course_id => course.id, :description => 'test')
|
||||
|
||||
# Deleta o curso
|
||||
course.destroy
|
||||
|
||||
# Ve o que aconteceu com os objetos
|
||||
assert_raises(ActiveRecord::RecordNotFound) { Attachment.find(attachment.id) }
|
||||
assert_raises(ActiveRecord::RecordNotFound) { WikiPage.find(wiki_page.id) }
|
||||
assert_raises(ActiveRecord::RecordNotFound) { CourseShoutboxMessage.find(shoutbox_message.id) }
|
||||
assert_raises(ActiveRecord::RecordNotFound) { News.find(news_message.id) }
|
||||
assert_raises(ActiveRecord::RecordNotFound) { Event.find(event.id) }
|
||||
def test_truth
|
||||
assert true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user