Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
consistency in code style..ish [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
cycomachead committed Apr 22, 2015
1 parent 2c054a4 commit e55c039
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions spec/controllers/api/v1/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@

describe "GET #show" do
before(:each) do
#Added by steve for alec
fakeuser = double('user')
allow(request.env['warden']).to receive(:authenticate!).and_return(fakeuser)
allow(controller).to receive(:current_user).and_return(fakeuser)



@user = FactoryGirl.create :user
get :show, id: @user.id, format: :json

end

it "returns the information about a reporter on a hash" do
it "renders json with the users info" do
user_response = JSON.parse(response.body, symbolize_names: true)
expect(user_response[:email]).to eql @user.email
end
Expand All @@ -30,12 +27,10 @@
end

describe "POST #create" do

context "when is successfully created" do
context "when a user is successfully created" do
before(:each) do
@user_attrs = FactoryGirl.attributes_for :user

# Added by steve for alec
fakeuser = double('user')
allow(request.env['warden']).to receive(:authenticate!).and_return(fakeuser)
allow(controller).to receive(:current_user).and_return(fakeuser)
Expand All @@ -51,13 +46,12 @@
it { should respond_with 201 }
end

context "when is not created" do
context "when a user is not created" do
before(:each) do
#notice I'm not including the email
# notice I'm not including the email
@invalid_user_attributes = { password: "12345678",
password_confirmation: "12345678" }

#Added by steve for alec
fakeuser = double('user')
allow(request.env['warden']).to receive(:authenticate!).and_return(fakeuser)
allow(controller).to receive(:current_user).and_return(fakeuser)
Expand All @@ -66,12 +60,12 @@
post :create, { user: @invalid_user_attributes }, format: :json
end

it "renders an errors json" do
it "renders json with errors" do
user_response = JSON.parse(response.body, symbolize_names: true)
expect(user_response).to have_key(:errors)
end

it "renders the json errors on why the user could not be created" do
it "renders json errors for why the user could not be created" do
user_response = JSON.parse(response.body, symbolize_names: true)
expect(user_response[:errors][:email]).to include "can't be blank"
end
Expand All @@ -84,23 +78,19 @@
before(:each) do
@user = FactoryGirl.create :user

#Added by steve for alec
fakeuser = double('user')
allow(request.env['warden']).to receive(:authenticate!).and_return(fakeuser)
allow(controller).to receive(:current_user).and_return(fakeuser)

delete :destroy, { id: @user.id }, format: :json


end

it { should respond_with 204 }

end

describe "PUT/PATCH #update" do

context "when is successfully updated" do
context "when a user successfully updated" do
before(:each) do
@user = FactoryGirl.create :user

Expand Down

0 comments on commit e55c039

Please sign in to comment.