administration_test.rb 728 B

1234567891011121314151617181920212223242526272829
  1. require 'test_helper'
  2. class AdministrationTest < ActiveSupport::TestCase
  3. def setup
  4. @admin = users(:daniel)
  5. @school = schools(:one)
  6. @administration = Administration.new(user_id: @admin.id,
  7. school_id: @school.id)
  8. end
  9. test "should be valid" do
  10. assert @administration.valid?
  11. end
  12. test "should destroy administration when user is destroyed" do
  13. @administration.save
  14. assert_difference "@school.administrators.count", -1 do
  15. @admin.destroy
  16. end
  17. end
  18. test "should destroy administration when school is destroyed" do
  19. @administration.save
  20. assert_difference "@admin.schools_administering.count", -1 do
  21. @school.destroy
  22. end
  23. end
  24. end