From 4f674d3d3c9a67f7ead980ebb9f3c395a5d4c313 Mon Sep 17 00:00:00 2001 From: Alberto Bellotti Date: Mon, 6 Mar 2017 13:19:27 -0500 Subject: [PATCH] Adding regions resource specs. --- spec/requests/api/regions_spec.rb | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 spec/requests/api/regions_spec.rb diff --git a/spec/requests/api/regions_spec.rb b/spec/requests/api/regions_spec.rb new file mode 100644 index 00000000000..4f16817d5c0 --- /dev/null +++ b/spec/requests/api/regions_spec.rb @@ -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