Skip to content

Commit

Permalink
Don't show interview_notes to non-admins
Browse files Browse the repository at this point in the history
  • Loading branch information
zachlatta committed Jan 28, 2018
1 parent 91ce005 commit 6e44b2b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
9 changes: 8 additions & 1 deletion api/app/serializers/new_club_application_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,17 @@ class NewClubApplicationSerializer < ActiveModel::Serializer
:curious_what_convinced,
:curious_how_did_hear,
:point_of_contact_id,
:submitted_at
:submitted_at,
:interviewed_at,
:interview_duration

attribute :interview_notes, if: :admin?

has_many :leader_profiles

# for admin? method
delegate :admin?, to: :current_user

class LeaderProfileSerializer < ActiveModel::Serializer
attributes :id, :completed_at
has_one :user
Expand Down
16 changes: 16 additions & 0 deletions api/spec/requests/v1/new_club_applications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,22 @@
'email' => profile.user.email
}
)

# includes interviewed_at and interview_duration, but not interview_notes
expect(json).to include('interviewed_at')
expect(json).to include('interview_duration')
expect(json).to_not include('interview_notes')
end

it 'includes interview_notes when authed as an admin' do
user.make_admin!
user.save

get "/v1/new_club_applications/#{club_application.id}",
headers: auth_headers

expect(response.status).to eq(200)
expect(json).to include('interview_notes')
end

it '404s when application does not exist' do
Expand Down

0 comments on commit 6e44b2b

Please sign in to comment.