Skip to content

Instantly share code, notes, and snippets.

@thieso2
Created July 12, 2013 12:12
Show Gist options
  • Select an option

  • Save thieso2/5984000 to your computer and use it in GitHub Desktop.

Select an option

Save thieso2/5984000 to your computer and use it in GitHub Desktop.
test 'gets index as json' do
user1 = user2 = nil
without_access_control do
User.destroy_all
user1 = FactoryGirl.create(:user, role: "user")
user2 = FactoryGirl.create(:user, role: "admin")
end
sign_in user1
get :index, :format => :json
assert_equal [{
"id"=>user1.id,
"first_name"=>user1.first_name,
"last_name"=>user1.last_name,
"avatar"=>"",
"online"=>true,
"role"=>"user"
}, {
"id"=>user2.id,
"first_name"=>user2.first_name,
"last_name"=>user2.last_name,
"avatar"=>"",
"online"=>false,
"role"=>"admin"
}], JSON.parse(response.body)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment