Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/controllers/api/ownership_transfers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def show
if @ownership_transfer.blank? || cannot?(:read, @ownership_transfer)
head :not_found
elsif current_user_is_requester?
render json: { status: @ownership_transfer.status, you_are: 'owner', nominee_name: nominee_name }, status: :ok
render json: { status: @ownership_transfer.status, you_are: 'owner', nominee_name:, nominee_email: }, status: :ok
else
render json: { status: @ownership_transfer.status, you_are: 'nominee' }, status: :ok
end
Expand Down Expand Up @@ -49,5 +49,9 @@ def current_user_is_requester?
def nominee_name
User.from_userinfo(ids: @ownership_transfer.nominated_user_id).first&.name
end

def nominee_email
@ownership_transfer.email_address
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@
expect(json['nominee_name']).to eq(nominee.name)
end

it 'includes the nominated teacher\'s email' do
get("/api/schools/#{school.id}/ownership_transfer", headers:)

json = JSON.parse(response.body)
expect(json['nominee_email']).to eq(ownership_transfer.email_address)
end

it 'includes the transfer status' do
get("/api/schools/#{school.id}/ownership_transfer", headers:)

Expand Down Expand Up @@ -114,7 +121,7 @@

expect(response).to have_http_status(:ok)
json = JSON.parse(response.body)
expect(json).to include('status' => 'completed', 'you_are' => 'owner', 'nominee_name' => nominee.name)
expect(json).to include('status' => 'completed', 'you_are' => 'owner', 'nominee_name' => nominee.name, 'nominee_email' => ownership_transfer.email_address)
end
end

Expand Down
Loading