Sha256: ccec16daf9d8e1a60935714bb58097e301424847207bc0061746d599c787f217

Contents?: true

Size: 1.23 KB

Versions: 11

Compression:

Stored size: 1.23 KB

Contents

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

11 entries across 11 versions & 1 rubygems

Version Path
social_networking-0.11.8 spec/controllers/social_networking/profiles_controller_spec.rb
social_networking-0.11.7 spec/controllers/social_networking/profiles_controller_spec.rb
social_networking-0.11.6 spec/controllers/social_networking/profiles_controller_spec.rb
social_networking-0.11.5 spec/controllers/social_networking/profiles_controller_spec.rb
social_networking-0.11.4 spec/controllers/social_networking/profiles_controller_spec.rb
social_networking-0.11.3 spec/controllers/social_networking/profiles_controller_spec.rb
social_networking-0.11.2 spec/controllers/social_networking/profiles_controller_spec.rb
social_networking-0.11.1 spec/controllers/social_networking/profiles_controller_spec.rb
social_networking-0.11.0 spec/controllers/social_networking/profiles_controller_spec.rb
social_networking-0.10.0 spec/controllers/social_networking/profiles_controller_spec.rb
social_networking-0.9.3 spec/controllers/social_networking/profiles_controller_spec.rb