Skip to content

Commit ca9b37c

Browse files
fixed tests
1 parent faa4dea commit ca9b37c

6 files changed

+12
-12
lines changed

app/models/dns/domain_name.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def reserved?
7171
end
7272

7373
def bsa_protected?
74-
BsaProtectedDomain.where(name: name).any?
74+
BsaProtectedDomain.where(domain_name: name).any?
7575
end
7676

7777
def disputed?

app/services/bsa/application_service.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ def struct_response(response)
3232
parsed_data = parse_response(response)
3333
result = [OK, ACCEPTED].include? response.code
3434

35-
Struct.new(:result?, :error).new(result, OpenStruct.new(parsed_data)) unless result
35+
return Struct.new(:result?, :error).new(result, OpenStruct.new(parsed_data)) unless result
3636

37-
if parsed_data.is_a?(Array)
37+
if parsed_data.is_a?(Array)
3838
Struct.new(:result?, :body).new(result, parsed_data.map { |data| OpenStruct.new(data) })
3939
else
4040
Struct.new(:result?, :body).new(result, OpenStruct.new(parsed_data))

app/services/bsa/block_order_list_service.rb

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def initialize(sort_by:, order:, offset:, limit:, q:)
1919

2020
def call
2121
http = connect(url: base_url)
22-
2322
response = http.get(endpoint, headers.merge(token_format(token)))
2423

2524
struct_response(response)

test/services/bsa/block_order_list_service_test.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'test_helper'
22

3-
RESPONSE = {
3+
RESPONSE_BLOCK_ORDER_LIST_SERVICE = {
44
"list": [
55
{
66
"blockSubOrderId": 690_680_666_563_633,
@@ -71,13 +71,14 @@ def test_for_succesfull_block_order_list
7171
stub_request(:get, 'https://api-ote.bsagateway.co/bsa/api/blockrsporder')
7272
.to_return(
7373
status: 200,
74-
body: RESPONSE.to_json,
74+
body: RESPONSE_BLOCK_ORDER_LIST_SERVICE.to_json,
7575
headers: { 'Content-Type' => 'application/json' }
7676
)
7777

7878
r = Bsa::BlockOrderListService.call
7979

8080
assert r.result?
81+
8182
assert_equal r.body.list.count, 2
8283
end
8384

@@ -103,7 +104,7 @@ def test_parse_query_parameters
103104

104105
result = instance_serive.send(:query_string)
105106

106-
assert_equal result, 'sortBy=createdAt&order=desc&offset=0&limit=100&tld=test'
107+
assert_equal result, 'sortBy=createdBy&order=desc&offset=0&limit=100&q=tld%3Dtest'
107108
end
108109

109110
private

test/services/bsa/block_order_view_service_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require 'test_helper'
44

5-
RESPONSE = {
5+
RESPONSE_BLOCK_VIEW_SERVICE = {
66
"list": %w[
77
label1
88
label2
@@ -32,7 +32,7 @@ def test_for_succesfull_block_order_list
3232
stub_request(:get, 'https://api-ote.bsagateway.co/bsa/api/blockrsporder/labels?blocksuborderid=1')
3333
.to_return(
3434
status: 200,
35-
body: RESPONSE.to_json,
35+
body: RESPONSE_BLOCK_VIEW_SERVICE.to_json,
3636
headers: { 'Content-Type' => 'application/json' }
3737
)
3838

test/services/bsa/download_non_blocked_name_list_service_test.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require 'test_helper'
44

5-
RESPONSE = 'some,csv,data'
5+
RESPONSE_DOWNLOAD = 'some,csv,data'
66

77
class Bsa::BlockOrderViewServiceTest < ActiveSupport::TestCase
88
setup do
@@ -19,15 +19,15 @@ def test_for_succesfull_downloaded_non_blocked_name
1919
stub_request(:get, 'https://api-ote.bsagateway.co/bsa/api/blockrsporder/1/nonblockednames')
2020
.to_return(
2121
status: 200,
22-
body: RESPONSE.to_json,
22+
body: RESPONSE_DOWNLOAD.to_json,
2323
headers: { 'Content-Type' => 'text/csv',
2424
'Content-Disposition' => 'attachment; filename="mock-csv.csv"' }
2525
)
2626

2727
result = Bsa::DownloadNonBlockedNameListService.call(suborder_id: 1, filename: @filename)
2828

2929
assert File.exist?("#{@filename}.csv")
30-
assert_equal RESPONSE, File.read("#{@filename}.csv").gsub('"', '')
30+
assert_equal RESPONSE_DOWNLOAD, File.read("#{@filename}.csv").gsub('"', '')
3131
assert result.result?
3232
assert_equal "Data was added to #{@filename}.csv file", result.body.message
3333
end

0 commit comments

Comments
 (0)