From 83e67e1be3172c8d175575ccb329321140e01dd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20B=C3=A9n=C3=A9?= Date: Thu, 8 Apr 2021 13:39:34 -0400 Subject: [PATCH 1/2] add find company endpoints --- lib/lightspeed_restaurant/company.rb | 1 + spec/fixtures/vcr_cassettes/company/find.yml | 42 ++++++++++++++++++++ spec/lightspeed_restaurant/company_spec.rb | 11 +++++ 3 files changed, 54 insertions(+) create mode 100644 spec/fixtures/vcr_cassettes/company/find.yml diff --git a/lib/lightspeed_restaurant/company.rb b/lib/lightspeed_restaurant/company.rb index d7650e7..d8db62d 100644 --- a/lib/lightspeed_restaurant/company.rb +++ b/lib/lightspeed_restaurant/company.rb @@ -5,6 +5,7 @@ module LightspeedRestaurantClient class Company < LightspeedRestaurantClient::Base + extend Operations::Find extend Operations::List def self.resource_name diff --git a/spec/fixtures/vcr_cassettes/company/find.yml b/spec/fixtures/vcr_cassettes/company/find.yml new file mode 100644 index 0000000..388b70e --- /dev/null +++ b/spec/fixtures/vcr_cassettes/company/find.yml @@ -0,0 +1,42 @@ +--- +http_interactions: +- request: + method: get + uri: http://staging-integration.posios.com/PosServer/rest/core/company/14160 + body: + encoding: UTF-8 + string: "{}" + headers: + User-Agent: + - excon/0.45.4 + Content-Type: + - application/json + X-Auth-Token: + - API_TOKEN_VALUE + response: + status: + code: 200 + message: '' + headers: + Date: + - Thu, 13 Apr 2017 20:27:03 GMT + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - POST, PUT, GET, OPTIONS, DELETE + Access-Control-Max-Age: + - '3600' + Access-Control-Allow-Headers: + - x-auth-token, x-requested-with, content-type + Content-Type: + - application/json;charset=UTF-8 + Content-Length: + - '69' + Server: + - Jetty(8.1.16.v20140903) + body: + encoding: UTF-8 + string: '{"id":14160,"name":"Chronogolf","vatInclusive":true,"country":"US"}' + http_version: + recorded_at: Thu, 13 Apr 2017 20:27:03 GMT +recorded_with: VCR 3.0.1 diff --git a/spec/lightspeed_restaurant/company_spec.rb b/spec/lightspeed_restaurant/company_spec.rb index 2332da8..e7a958c 100644 --- a/spec/lightspeed_restaurant/company_spec.rb +++ b/spec/lightspeed_restaurant/company_spec.rb @@ -16,5 +16,16 @@ module LightspeedRestaurantClient let(:results_count) { 1 } end end + + context 'when finding' do + it_behaves_like 'a find operation' do + let(:resource_id) { 14160 } + + it 'returns the company datas' do + result = described_class.find(resource_id) + expect(result.id).to eq 14160 + end + end + end end end From ab53a5fcb9e25766984c586cb82848d010a88402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20B=C3=A9n=C3=A9?= Date: Thu, 8 Apr 2021 14:42:17 -0400 Subject: [PATCH 2/2] Update spec/lightspeed_restaurant/company_spec.rb --- spec/lightspeed_restaurant/company_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lightspeed_restaurant/company_spec.rb b/spec/lightspeed_restaurant/company_spec.rb index e7a958c..241131f 100644 --- a/spec/lightspeed_restaurant/company_spec.rb +++ b/spec/lightspeed_restaurant/company_spec.rb @@ -21,7 +21,7 @@ module LightspeedRestaurantClient it_behaves_like 'a find operation' do let(:resource_id) { 14160 } - it 'returns the company datas' do + it "returns the company's data" do result = described_class.find(resource_id) expect(result.id).to eq 14160 end