Skip to content

Commit

Permalink
Merge pull request #44 from gocardless/hmac/register-view
Browse files Browse the repository at this point in the history
Allow register_view to be specified for persons-with-significant-control
  • Loading branch information
Harry Maclean authored Mar 6, 2018
2 parents adf34be + 476ffcb commit b01e037
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/companies_house/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ def officers(id)
get_all_pages(:officers, "company/#{id}/officers", id)
end

def persons_with_significant_control(id)
def persons_with_significant_control(id, register_view: false)
get_all_pages(
:persons_with_significant_control,
"company/#{id}/persons-with-significant-control",
id,
register_view: true,
register_view: register_view,
)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/companies_house/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module CompaniesHouse
VERSION = "0.4.0"
VERSION = "0.4.1"
end
18 changes: 15 additions & 3 deletions spec/companies_house/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,16 @@
describe "#persons_with_significant_control" do
include_context "test client"

subject(:response) { client.persons_with_significant_control(company_id) }
subject(:response) do
client.persons_with_significant_control(company_id, register_view: register_view)
end

let(:rest_path) do
"company/#{company_id}/persons-with-significant-control?register_view=true"
"company/#{company_id}/persons-with-significant-control" \
"?register_view=#{register_view}"
end
let(:request_method) { "persons_with_significant_control" }
let(:register_view) { true }

context "when all results are on a single page" do
let(:single_page) do
Expand All @@ -220,13 +224,21 @@
stub_request(:get, "#{example_endpoint}/#{rest_path}").
with(
basic_auth: [api_key, ""],
query: { "start_index" => 0, register_view: true },
query: { "start_index" => 0, register_view: register_view },
).to_return(body: single_page, status: status)
end

it "returns items from the one, single page" do
expect(response).to eq(%w[item1 item2])
end

context "with register_view: false" do
let(:register_view) { false }

it "returns items from the one, single page" do
expect(response).to eq(%w[item1 item2])
end
end
end

context "when results are spread across several pages" do
Expand Down

0 comments on commit b01e037

Please sign in to comment.