diff --git a/app/controllers/emails_controller.rb b/app/controllers/emails_controller.rb index 7f10f33f4..0a328baa5 100644 --- a/app/controllers/emails_controller.rb +++ b/app/controllers/emails_controller.rb @@ -2,6 +2,13 @@ class EmailsController < ApplicationController before_action :member_only respond_to :html, :xml, :json + def show + @user = User.find(params[:user_id]) + check_privilege(@user) + + respond_with(@user.email_address) + end + def edit @user = User.find(params[:user_id]) check_privilege(@user) diff --git a/config/routes.rb b/config/routes.rb index 8c6e9a25c..9a1a34033 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -245,7 +245,7 @@ Rails.application.routes.draw do end resources :users do resources :favorite_groups, controller: "favorite_groups", only: [:index], as: "favorite_groups" - resource :email, only: [:edit, :update] do + resource :email, only: [:show, :edit, :update] do get :verify end resource :password, only: [:edit, :update] diff --git a/test/functional/emails_controller_test.rb b/test/functional/emails_controller_test.rb index cb22fbe78..ae7b7b297 100644 --- a/test/functional/emails_controller_test.rb +++ b/test/functional/emails_controller_test.rb @@ -6,6 +6,13 @@ class EmailsControllerTest < ActionDispatch::IntegrationTest @user = create(:user, email_address: build(:email_address, { address: "bob@ogres.net", is_verified: false })) end + context "#show" do + should "render" do + get_auth user_email_path(@user), @user, as: :json + assert_response :success + end + end + context "#edit" do should "render" do get_auth edit_user_email_path(@user), @user