Skip to content

Commit

Permalink
[precheck] allow precheck to be run on live app versions as well as e…
Browse files Browse the repository at this point in the history
…dit ones (fastlane#17738)

* Allow precheck to be run on live app versions as well.

* Fix specs.

* Add option to force precheck to use the live app version.

* Read `use_live` when fetching `latest_app_version`.
  • Loading branch information
rogerluan authored Dec 31, 2020
1 parent 0e4d620 commit 5fc4064
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
7 changes: 6 additions & 1 deletion precheck/lib/precheck/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ def self.available_options
description: "Should check in-app purchases?",
is_string: false,
optional: true,
default_value: true)
default_value: true),
FastlaneCore::ConfigItem.new(key: :use_live,
env_name: "PRECHECK_USE_LIVE",
description: "Should force check live app?",
is_string: false,
default_value: false)
] + rules
end
end
Expand Down
2 changes: 1 addition & 1 deletion precheck/lib/precheck/rule_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def self.generate_app_items_to_check(app: nil)
items = []

# App info localizations
app_info = app.fetch_edit_app_info
app_info = Precheck.config[:use_live] ? app.fetch_live_app_info : app.fetch_latest_app_info
app_info_localizations = app_info.get_app_info_localizations
app_info_localizations.each do |localization|
items << collect_text_items_from_language_item(locale: localization.locale,
Expand Down
2 changes: 1 addition & 1 deletion precheck/lib/precheck/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def app

def latest_app_version
platform = Spaceship::ConnectAPI::Platform.map(Precheck.config[:platform])
@latest_version ||= app.get_edit_app_store_version(platform: platform)
@latest_version ||= Precheck.config[:use_live] ? app.get_live_app_store_version(platform: platform) : app.get_latest_app_store_version(platform: platform)
end

# Makes sure the current App ID exists. If not, it will show an appropriate error message
Expand Down
2 changes: 1 addition & 1 deletion precheck/spec/rule_processor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def setup_happy_app
allow(fake_happy_app).to receive(:name).and_return("My Fake App")
allow(fake_happy_app).to receive(:in_app_purchases).and_return(fake_in_app_purchases)

allow(fake_happy_app).to receive(:fetch_edit_app_info).and_return(fake_happy_app_info)
allow(fake_happy_app).to receive(:fetch_latest_app_info).and_return(fake_happy_app_info)
allow(fake_happy_app_info).to receive(:get_app_info_localizations).and_return([fake_info_localization])

allow(fake_happy_app_version).to receive(:copyright).and_return("Copyright taquitos, #{DateTime.now.year}")
Expand Down
6 changes: 6 additions & 0 deletions spaceship/lib/spaceship/connect_api/models/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ def fetch_edit_app_info(client: nil, includes: Spaceship::ConnectAPI::AppInfo::E
end.first
end

def fetch_latest_app_info(client: nil, includes: Spaceship::ConnectAPI::AppInfo::ESSENTIAL_INCLUDES)
client ||= Spaceship::ConnectAPI
resp = client.get_app_infos(app_id: id, includes: includes)
return resp.to_models.first
end

#
# Available Territories
#
Expand Down

0 comments on commit 5fc4064

Please sign in to comment.