Add basic test for answer & user show views
This commit is contained in:
parent
32e6975c28
commit
7e57735b88
|
@ -1,6 +1,6 @@
|
|||
class AnswerController < ApplicationController
|
||||
def show
|
||||
@answer = Answer.find(params[:id]).include(comments: [:user, :smiles], question: [:user], smiles: [:user])
|
||||
@answer = Answer.includes(comments: [:user, :smiles], question: [:user], smiles: [:user]).find(params[:id])
|
||||
@display_all = true
|
||||
|
||||
if user_signed_in?
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe AnswerController do
|
||||
let(:user) { FactoryBot.create :user,
|
||||
otp_module: :disabled,
|
||||
otp_secret_key: 'AAAAAAAA'}
|
||||
let(:answer) { FactoryBot.create :answer, user: user }
|
||||
|
||||
describe "#show" do
|
||||
subject { get :show, params: { username: user.screen_name, id: answer.id } }
|
||||
|
||||
context "user signed in" do
|
||||
before(:each) { sign_in user }
|
||||
|
||||
it "renders the answer/show template" do
|
||||
subject
|
||||
expect(assigns(:answer)).to eq(answer)
|
||||
expect(response).to render_template("answer/show")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -7,13 +7,27 @@ describe UserController, type: :controller do
|
|||
otp_module: :disabled,
|
||||
otp_secret_key: 'EJFNIJPYXXTCQSRTQY6AG7XQLAT2IDG5H7NGLJE3'}
|
||||
|
||||
describe "#show" do
|
||||
subject { get :show, params: { username: user.screen_name } }
|
||||
|
||||
context "user signed in" do
|
||||
before(:each) { sign_in user }
|
||||
|
||||
it "renders the user/show template" do
|
||||
subject
|
||||
expect(assigns(:user)).to eq(user)
|
||||
expect(response).to render_template("user/show")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#edit" do
|
||||
subject { get :edit }
|
||||
|
||||
context "user signed in" do
|
||||
before(:each) { sign_in user }
|
||||
|
||||
it "renders the edit_profile_picture template" do
|
||||
it "renders the user/edit template" do
|
||||
subject
|
||||
expect(response).to render_template("user/edit")
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue