Skip to content
This repository has been archived by the owner on Jul 25, 2019. It is now read-only.

Commit

Permalink
Fix deletion tests to support new model.
Browse files Browse the repository at this point in the history
  • Loading branch information
raimo committed Jan 3, 2014
1 parent 51a6658 commit 9a9f837
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions spec/lib/uservoice/client_spec.rb
Expand Up @@ -99,7 +99,7 @@

it "should update the email of the current user" do
user = subject.login_as('mailaddress@example.com') do |token|
token.put("/api/v1/users/0", :user => {
token.put("/api/v1/users/current", :user => {
:email => 'mailaddress123@example.com'
})
token.get("/api/v1/users/current")['user']
Expand Down Expand Up @@ -194,19 +194,20 @@
end

it "should be able to delete itself" do
my_token = subject.login_as('somebodythere@example.com')
owner = subject.login_as_owner
user_count_1st = owner.get_collection("/api/v1/users.json").size
my_token = subject.login_as('somenewthere@example.com')

user_count_1st.should == owner.get_collection("/api/v1/users.json").size - 1

# whoami
my_id = my_token.get("/api/v1/users/current.json")['user']['id']

# Delete myself!
my_token.delete("/api/v1/users/#{my_id}.json")['user']['id'].should == my_id

# I don't exist anymore
lambda {
my_token.get("/api/v1/users/current.json")
}.should raise_error(UserVoice::NotFound)
user_count_1st.should == owner.get_collection("/api/v1/users.json").size
end

it 'should throw 404 if user not found' do
lambda {
subject.login_as_owner.get("/api/v1/users/2345871235")
Expand All @@ -216,6 +217,7 @@
it "should/be able to delete random user and login as him after that" do
somebody = subject.login_as('somebodythere@example.com')
owner = subject.login_as_owner
user_count = owner.get_collection("/api/v1/users.json").size

# somebody is still there...
regular_user = somebody.get("/api/v1/users/current.json")['user']
Expand All @@ -225,9 +227,7 @@
owner.delete("/api/v1/users/#{regular_user['id']}.json")['user']['id'].should == regular_user['id']

# not found anymore!
lambda {
somebody.get("/api/v1/users/current.json")['errors']['type']
}.should raise_error(UserVoice::NotFound)
user_count.should == owner.get_collection("/api/v1/users.json").size + 1

# this recreates somebody
somebody = subject.login_as('somebodythere@example.com')
Expand Down

0 comments on commit 9a9f837

Please sign in to comment.