create @person = current_account.people.create!(people_params) WelcomeMailer.deliver_welcome(@person) respond_to do |format| format.html do redirect_to @person end format.json do render :show, status: :created, location: @person end end end end
create @result = PersonCreateCommand.call(current_account, current_person, people_params) respond_to do |format| format.html do redirect_to @result.object end format.json do render :show, status: :created, location: @result.object end end end end
= create(:user) end describe "GET 'index'" do it "returns http success when authenticated with a token" do get :index expect(response).to be_success end it "returns 401 unauthorized when not authenticated with a token" do @request.headers["Authorization"] = nil get :index expect(response.status).to eq(401) end it "returns 401 unauthorized when not authenticated as an admin" do inject_token(@user) get :index expect(response.status).to eq(401) end it "returns all of the things" do create_list(:thing, 5) get :index expect(json_response.length).to eq(5) end end end