Sha256: 2c75339117aefca71af36a18250e54819d60768ee21d2b133598cff0b9549fcc

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true
require "spec_helper"

module SocialNetworking
  describe ProfilesController, type: :controller do
    context "participant is authenticated" do
      let(:participant) { instance_double(Participant) }
      let(:profile) { instance_double(Profile) }

      before do
        @routes = Engine.routes

        expect(controller).to receive(:current_participant) { participant }
        expect(participant)
          .to receive(:social_networking_profile) { profile }
      end

      describe "PUT update" do
        context "update succeeds" do
          it "renders serialized profile" do
            expect(profile).to receive_messages(update: true)
            expect(Serializers::ProfileSerializer)
              .to receive_message_chain(:new, :to_serialized)

            put :update, id: 1

            assert_response 200
          end
        end

        context "update fails" do
          let(:errors) { double("errors", full_messages: ["epic fail"]) }

          it "renders error message" do
            expect(profile).to receive_messages(update: false, errors: errors)

            put :update, id: 1

            assert_response 400
            expect(json["error"]).to eq ["epic fail"]
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
social_networking-0.13.3 spec/controllers/social_networking/profiles_controller_spec.rb
social_networking-0.13.2 spec/controllers/social_networking/profiles_controller_spec.rb
social_networking-0.13.1 spec/controllers/social_networking/profiles_controller_spec.rb
social_networking-0.13.0 spec/controllers/social_networking/profiles_controller_spec.rb
social_networking-0.12.0 spec/controllers/social_networking/profiles_controller_spec.rb