Sha256: 9f42cae1b164be92f004ca66de9ec587169bea0353541e576ee7b896061528e1

Contents?: true

Size: 1.77 KB

Versions: 11

Compression:

Stored size: 1.77 KB

Contents

require "spec_helper"

module SocialNetworking
  describe ProfilePagesController, type: :controller do
    let(:group) { double("group", social_networking_profile_questions: []) }
    let(:participant) do
      instance_double(
        Participant,
        active_group: group,
        id: 1)
    end
    let(:profile) { instance_double(Profile, participant_id: 1, active: nil) }
    let(:initiator) { instance_double(Participant) }
    let(:nudge) { instance_double(Nudge, initiator: initiator) }
    let(:status) { double("status") }

    describe "GET show" do
      context "when the current participant is authenticated" do
        before do
          @routes = Engine.routes
          allow(status).to receive(:context=)
          allow(controller).to receive(:current_participant) { participant }
          allow(participant).to receive(:navigation_status) { status }

          expect(controller).to receive(:store_nudge_initiators)
          expect(controller).to receive(:set_member_profiles)
        end

        context "when params contains profile id" do
          it "finds profile" do
            expect(Profile).to receive(:find) { profile }

            get :show, id: 1
          end

          it "sets the context of a participant's navigation status" do
            expect(Profile).to receive(:find) { profile }
            expect(status).to receive(:context=).with(nil)

            get :show, id: 1
          end
        end

        context "when viewing personal profile" do
          it "finds or initializes a new profile" do
            expect(Profile)
              .to receive(:find_or_initialize_by) { profile }
            expect(profile)
              .to receive(:update_attributes).with(active: true)

            get :show
          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/profile_pages_controller_spec.rb
social_networking-0.11.7 spec/controllers/social_networking/profile_pages_controller_spec.rb
social_networking-0.11.6 spec/controllers/social_networking/profile_pages_controller_spec.rb
social_networking-0.11.5 spec/controllers/social_networking/profile_pages_controller_spec.rb
social_networking-0.11.4 spec/controllers/social_networking/profile_pages_controller_spec.rb
social_networking-0.11.3 spec/controllers/social_networking/profile_pages_controller_spec.rb
social_networking-0.11.2 spec/controllers/social_networking/profile_pages_controller_spec.rb
social_networking-0.11.1 spec/controllers/social_networking/profile_pages_controller_spec.rb
social_networking-0.11.0 spec/controllers/social_networking/profile_pages_controller_spec.rb
social_networking-0.10.0 spec/controllers/social_networking/profile_pages_controller_spec.rb
social_networking-0.9.3 spec/controllers/social_networking/profile_pages_controller_spec.rb