Skip to content

Commit

Permalink
refactor: stop checking the license if in test env (#1804)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianthedev committed Jun 28, 2023
1 parent af82381 commit 9c36355
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 195 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

[*.key]
insert_final_newline = false
6 changes: 5 additions & 1 deletion lib/avo/licensing/h_q.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ def normalize_response(response)
def perform_request
::Rails.logger.debug "[Avo] Performing request to avohq.io API to check license availability." if Rails.env.development?

HTTParty.post ENDPOINT, body: payload.to_json, headers: {"Content-type": "application/json"}, timeout: REQUEST_TIMEOUT
if Rails.env.test?
OpenStruct.new({code: 200, parsed_response: {id: "pro", valid: true}})
else
HTTParty.post ENDPOINT, body: payload.to_json, headers: {"Content-type": "application/json"}, timeout: REQUEST_TIMEOUT
end
end

def app_name
Expand Down
2 changes: 1 addition & 1 deletion lib/avo/licensing/license.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class License
attr_accessor :valid
attr_accessor :payload

def initialize(response)
def initialize(response = {})
@response = response
@id = response["id"]
@valid = response["valid"]
Expand Down
2 changes: 1 addition & 1 deletion lib/avo/licensing/license_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def license
when "pro"
ProLicense.new @hq_response
else
NullLicense.new @hq_response
NilLicense.new @hq_response
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Avo
module Licensing
class NullLicense < License
class NilLicense < License
def initialize(response = nil)
response ||= {
id: "community",
Expand Down
Loading

0 comments on commit 9c36355

Please sign in to comment.