Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add links from dishonorable_discharges to user and officer

  • Loading branch information...
commit 8d4aeb699c94a257649a79b6d5567eeccbe51642 1 parent a67f180
Adam C. Baker authored
7 app/models/dishonorable_discharge.rb
@@ -11,4 +11,11 @@ class DishonorableDischarge < ActiveRecord::Base
11 11 end
12 12 end
13 13
  14 + after_save do |discharge|
  15 + discharge.user.discharged = true
  16 + discharge.user.save
  17 + end
  18 +
  19 + belongs_to :user
  20 + belongs_to :officer, class_name: 'User'
14 21 end
19 spec/models/dishonorable_discharge_spec.rb
@@ -46,4 +46,23 @@
46 46 @discharge.should_not be_valid
47 47 end
48 48
  49 + describe 'relationships' do
  50 + before :each do
  51 + @discharge.save!
  52 + end
  53 +
  54 + it 'should have the discharged user' do
  55 + @discharge.user.should == @user
  56 + end
  57 +
  58 + it 'should mark the user as discharged' do
  59 + #find the user to ensure discharged status is saved in the db
  60 + User.find(@user.id).should be_discharged
  61 + end
  62 +
  63 + it 'should have the discharging officer' do
  64 + @discharge.officer.should == @officer
  65 + end
  66 + end
  67 +
49 68 end

0 comments on commit 8d4aeb6

Please sign in to comment.
Something went wrong with that request. Please try again.