Sha256: 0534216a6d5285c964c6d5fa2edab75a1d319f7fcee6a640f157109b923b6e76

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

describe OpenSesame::Member, :vcr, :record => :new_episodes do
  ROSSTA_GITHUB_ID = 11673

  describe "self.find" do
    it "retrieves attributes from github" do
      member = OpenSesame::Member.find(ROSSTA_GITHUB_ID)
      member.should be_a(OpenSesame::Member)
      member.id.should == ROSSTA_GITHUB_ID
      member.login.should == 'rossta'
    end

    it "returns nil if no github member found" do
      nonexisting_id = -1
      member = OpenSesame::Member.find(nonexisting_id)
      member.should be_nil
    end

    context "github api" do
      let(:github_api) { mock('Octokit') }

      before do
        OpenSesame::Member.stub!(:github_api => github_api)
      end

      it "looks up organization member for given id" do
        github_api.should_receive(:organization_members).with(OpenSesame.organization_name).and_return([])
        OpenSesame::Member.find(123)
      end

      it "skips lookup if no id given" do
        github_api.should_not_receive(:organization_members)
        OpenSesame::Member.find(nil)
      end
    end
  end

  describe "warden serialization" do
    let(:member) { OpenSesame::Member.find(ROSSTA_GITHUB_ID) }

    it "serialize_into_session returns given member.id in array" do
      OpenSesame::Member.serialize_into_session(member).should eq([ROSSTA_GITHUB_ID])
    end

    it "serialize_from_session returns member from given member id" do
      OpenSesame::Member.serialize_from_session(ROSSTA_GITHUB_ID).should eq(member)
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
opensesame-0.1.2 spec/lib/open_sesame/member_spec.rb
opensesame-0.1.1 spec/lib/open_sesame/member_spec.rb
opensesame-0.1.0 spec/lib/open_sesame/member_spec.rb