Skip to content

Commit

Permalink
Update release notes extractor spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoy committed Oct 6, 2024
1 parent b68c21f commit 5cfcbca
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Fastlane
UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)

module Helper
class AsanaHelper
class AsanaHelper # rubocop:disable Metrics/ClassLength
ASANA_API_URL = "https://app.asana.com/api/1.0"
ASANA_TASK_URL_TEMPLATE = "https://app.asana.com/0/0/%s/f"
ASANA_TAG_URL_TEMPLATE = "https://app.asana.com/0/%s/list"
Expand Down Expand Up @@ -426,9 +426,7 @@ def self.get_task_ids_from_git_log(from_ref, to_ref = "HEAD")

def self.fetch_release_notes(release_task_id, asana_access_token, output_type: "asana")
asana_client = make_asana_client(asana_access_token)

release_task_body = asana_client.tasks.get_task(task_gid: release_task_id, options: { fields: ["notes"] }).notes

ReleaseTaskHelper.extract_release_notes(release_task_body, output_type: output_type)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def extract_release_notes(task_body)
end
end

UI.user_error!("No release notes found") unless has_content
UI.user_error!("No release notes found") unless @has_content

@notes
end
Expand Down
20 changes: 20 additions & 0 deletions spec/asana_release_notes_extractor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@
end
end

shared_context "empty task body" do
before do
@input = ""
end
end

shared_examples "extracting release notes" do |mode|
it "extracts release notes in #{mode} format" do
expect(subject.extract_release_notes(@input)).to eq(@output[mode.to_sym])
Expand Down Expand Up @@ -302,6 +308,20 @@
include_context "non-empty release notes and Privacy Pro release header as a bullet point inside regular release notes"
it_behaves_like "extracting release notes", mode
end

context "empty task body" do
include_context "empty task body"

before do
allow(Fastlane::UI).to receive(:user_error!)
end

it "shows error" do
subject.extract_release_notes(@input)

expect(Fastlane::UI).to have_received(:user_error!).with("No release notes found")
end
end
end
end
end

0 comments on commit 5cfcbca

Please sign in to comment.