Have activate user return json

- Change activate user from admin controller to return json
- Test that it returns json
- Remove unnessary test from log_out spec

This commit was created so that when you activate a user through the api
it returns a json response.
This commit is contained in:
Blake Erickson 2014-12-08 11:16:57 -07:00
parent f0dda91364
commit 1d0eccf710
2 changed files with 14 additions and 6 deletions

View file

@ -198,7 +198,7 @@ class Admin::UsersController < Admin::AdminController
def activate
guardian.ensure_can_activate!(@user)
@user.activate
render nothing: true
render json: success_json
end
def deactivate

View file

@ -360,16 +360,24 @@ describe Admin::UsersController do
end
end
context 'activate' do
before do
@reg_user = Fabricate(:inactive_user)
end
it "returns success" do
xhr :put, :activate, user_id: @reg_user.id
response.should be_success
json = ::JSON.parse(response.body)
json['success'].should == "OK"
end
end
context 'log_out' do
before do
@reg_user = Fabricate(:user)
end
it 'returns JSON' do
xhr :put, :log_out, user_id: @reg_user.id
::JSON.parse(response.body).should be_present
end
it "returns success" do
xhr :put, :log_out, user_id: @reg_user.id
response.should be_success