Skip to content

Commit

Permalink
Merge 333a861 into 954af5d
Browse files Browse the repository at this point in the history
  • Loading branch information
dklounge committed Jan 3, 2014
2 parents 954af5d + 333a861 commit 624e551
Showing 1 changed file with 60 additions and 5 deletions.
65 changes: 60 additions & 5 deletions spec/models/authorisation_spec.rb
Expand Up @@ -17,7 +17,7 @@
after(:each) { authorisation.run_callbacks(:initialize) }

it "runs setup" do
authorisation.should_receive(:setup)
authorisation.should_receive(:setup)
end
end
end
Expand All @@ -27,14 +27,69 @@
end

describe "#profile" do
pending
context 'when provider is not google_oauth2' do
it 'returns nil' do
authorisation.profile.should be_nil
end
end
context 'when provider is google_oauth2' do
it 'returns profile' do
authorisation.provider = "google_oauth2"
authorisation.profile.should == $google_plus.person
end
end
end

describe "#mention" do
pending
url = "http://www.example.com/"

context 'when provider is google_oauth2' do
it 'returns true' do
authorisation.provider = "google_oauth2"
authorisation.mention(url).should be_true
end
end

context 'when provider is not google_oauth2' do
it 'returns nil' do
authorisation.provider = "linkedin_oauth"
authorisation.mention(url).should be_nil
end
end
end

describe "self.find_or_create_from_auth_hash" do
pending
describe ".find_or_create_from_auth_hash" do
let(:auth_hash) {
{ 'provider' => "photographre",
'user_id' => 1,
'uid' => '1',
'info' => {:key => 'Rob is cool'},
'credentials' => {:key => 'true'},
'extra' => {:key => 'is secret'}
}
}

context 'when there is a persistent authorisation' do
it 'it updates and returns auth' do
auth = Authorisation.find_or_create_from_auth_hash(auth_hash)
auth.update_attributes(auth_hash)
auth.provider.should == "photographre"
auth.uid.should == "1"
auth.info.should == {:key => 'Rob is cool'}
auth.credentials.should == {:key => 'true'}
auth.extra.should == {:key => 'is secret'}
end
end

context 'when there is no persistent authorisation' do
it 'it finds or creates, and returns auth' do
auth2 = Authorisation.find_or_create_from_auth_hash(auth_hash)
auth2.provider.should == "photographre"
auth2.uid.should == "1"
auth2.info.should be_nil
auth2.credentials.should be_nil
auth2.extra.should be_nil
end
end
end
end

0 comments on commit 624e551

Please sign in to comment.