Skip to content

Commit

Permalink
Adding regions resource specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellotti committed Mar 6, 2017
1 parent 65f703f commit 4f674d3
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions spec/requests/api/regions_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#
# REST API Request Tests - Regions
#
# Regions primary collections:
# /api/regions
#
# Tests for:
# GET /api/regions/:id
#

describe "Regions API" do
it "forbids access to regions without an appropriate role" do
api_basic_authorize

run_get(regions_url)

expect(response).to have_http_status(:forbidden)
end

it "forbids access to a region resource without an appropriate role" do
api_basic_authorize

region = FactoryGirl.create(:miq_region, :region => "2")

run_get(regions_url(region.id))

expect(response).to have_http_status(:forbidden)
end

it "allows GETs of a region" do
api_basic_authorize action_identifier(:regions, :read, :resource_actions, :get)

region = FactoryGirl.create(:miq_region, :region => "2")

run_get(regions_url(region.id))

expect(response).to have_http_status(:ok)
expect(response.parsed_body).to include(
"href" => a_string_matching(regions_url(region.id)),
"id" => region.id
)
end
end

0 comments on commit 4f674d3

Please sign in to comment.