Skip to content

Commit

Permalink
Fixes Issue hotsh#698, the [email protected] case (attempting to follow…
Browse files Browse the repository at this point in the history
… a local user that doesn't exist using the remote form)
  • Loading branch information
gavinlaking authored and carols10cents committed Nov 17, 2012
1 parent 07157df commit 62d0780
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/services/finger_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ def finger!
@feed_data.url = data.url
@feed_data.finger_data = data
@feed_data

# TODO: other exceptions to rescue; check what Redfinger raises
rescue RestClient::ResourceNotFound
raise RstatUs::InvalidSubscribeTo
rescue SocketError
raise RstatUs::InvalidSubscribeTo
end
Expand Down
17 changes: 13 additions & 4 deletions test/services/finger_service_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,26 @@ class InvalidSubscribeTo < StandardError; end
subject
end

describe "with a local rstat.us email address that doesn't have a corresponding user" do
let(:target) { "[email protected]" }
before do
Redfinger.stubs(:finger).with(target).raises(RestClient::ResourceNotFound)
end

it "raises a RestClient::ResourceNotFound exception" do
lambda { subject }.must_raise RstatUs::InvalidSubscribeTo
end
end

describe "with an invalid ostatus email address" do
let(:target) { "ladygaga@twitter" }

before do
Redfinger.stubs(:finger).with(target).raises(SocketError)
end

it "raises a socket error" do
lambda {
FingerService.new(target).finger!
}.must_raise RstatUs::InvalidSubscribeTo
it "raises a SocketError exception" do
lambda { subject }.must_raise RstatUs::InvalidSubscribeTo
end
end
end
Expand Down

0 comments on commit 62d0780

Please sign in to comment.