Files
old-holivud2/spec/controllers/api/profiles_controller_spec.rb
2020-09-06 21:42:50 +02:00

32 lines
899 B
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Api::ProfilesController, type: :controller do
let(:current_user) { create(:user) }
describe '#show' do
it 'responds with profile info for the current user' do
sign_in_to_api(current_user)
get :show
expect(response).to be_successful
expect(response_body_data).to include('id' => current_user.to_param, 'type' => 'user')
expect(response_body_data_attributes).to include('email' => current_user.email)
expect(response_body_data_attributes).to include('full_name' => current_user.full_name)
expect(response_body_data_attributes).to include('company_name' => current_user.primary_account.name)
end
end
private
def response_body_data
JSON.parse(response.body).dig('data')
end
def response_body_data_attributes
response_body_data.dig('attributes')
end
end