This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it 'returns users with member privileges only' do | |
member = create(:user, :with_member_privilege) | |
create(:user, :with_admin_privilege) | |
create(:user, :with_member_privilege, :with_admin_privilege) | |
result = MembersOnlyQuery.call | |
expect(result).to match([member]) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
context 'when notifications service is disabled' do | |
it 'does not create project deletion notification for user' do | |
api_user = create(:user, :api) | |
api_user_account = create(:account, user: api_user) | |
notifier_client = instance_double(NotifierClient) | |
allow(NotifierClient).to receive(:for).with(api_user_account) { notifier_client } | |
allow(notifier_client).to receive(:active?) { false } | |
user = create(:user) | |
project = create(:project, name: "Zebra", owner: user) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
context 'when notifications service is disabled' do | |
it 'does not create project deletion notification for user' do | |
allow(notifier_client_double).to receive(:active?) { false } | |
user = create(:user) | |
project = create(:project, name: "Zebra", owner: user) | |
expect { DestroyProject.call(project) }.to_not change { Notification.count } | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe '#nightly_price_for' do | |
context 'when given night is not booked' do | |
context 'when given night is weekend night' do | |
context 'when weekend nightly rate is available for period' do | |
it 'returns weekend nightly rate for period' do | |
rates_table = <<~RATE_PLAN | |
Rate period | Nightly | Weekend Night | Weekly | Monthly | |
--------------------------------------------------------------------- | |
2017/07/20 - 2017/07/31 | 500 | 600 | 2800 | 30000 | |
2017/08/01 - 2017/08/10 | 200 | 400 (Sat,Sun) | 1400 | 20000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stub_request(:get, 'https://hotels.cloudbeds.com/api/v1.1/getRoomTypes') { { | |
body: | |
{ | |
'success' => true, | |
'data' => [ | |
{ | |
'roomTypeID' => '713', | |
'propertyID' => '276', | |
'roomTypeName' => 'AAA', | |
'roomTypeNameShort' => 'AAA', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stub_request(:get, 'https://hotels.cloudbeds.com/api/v1.1/getRoomTypes') { { | |
body: | |
{ | |
'success' => true, | |
'data' => [{ | |
'roomTypeID' => '713', 'propertyID' => '276', 'roomTypeName' => 'AAA', | |
'roomTypeNameShort' => 'AAA', 'roomTypeDescription' => 'asdfa', 'isPrivate' => false, | |
'maxGuests' => '1', 'adultsIncluded' => '1', 'childrenIncluded' => 0, | |
'roomsAvailable' => 3, 'roomRate' => 120, 'roomTypeUnits' => 10 | |
}], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
allow(ENV).to receive(:fetch).with('API_KEY') { '123' } | |
get '/v1/days', { 'Content-Type' => 'application/json', 'X-Api-Key' => api_key } | |
expect(JSON.parse(response.body)['data']).to include( | |
{ 'date' => '2018-04-20', 'sunset_at' => '19:47' }, | |
{ 'date' => '2018-04-21', 'sunset_at' => '19:48' }, | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get_json '/v1/days' | |
expect(json_response[:data]).to include( | |
{ date: '2018-04-20', sunset_at: '19:47' }, | |
{ date: '2018-04-21', sunset_at: '19:48' }, | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Support | |
module RequestHelpers | |
def get_json(path) | |
get path, headers: headers | |
end | |
def json_response | |
@json_response ||= HashWithIndifferentAccess.new(JSON.parse(response.body)) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To make it easier to find descriptions and add exceptions | |
AllCops: | |
DisplayCopNames: true | |
Exclude: | |
- 'bin/**/*' | |
- 'vendor/**/*' | |
- 'db/schema.rb' | |
- 'tmp/**/*' | |
- 'node_modules/**/*' |