@@ -301,6 +301,7 @@ def sanitize_asana_html_notes(content)
301301 expect ( @client ) . to receive ( :releases ) . with ( "iOS" , { page : 1 , per_page : 25 } )
302302
303303 expect ( Fastlane ::Helper ::AsanaHelper ) . to receive ( :fetch_release_notes ) . with ( "1234567890" , "secret-token" )
304+ expect ( Fastlane ::Helper ::AsanaHelper ) . to receive ( :validate_task_accessible ) . with ( "1234567890" , "secret-token" ) . and_return ( true )
304305 expect ( Fastlane ::Helper ::ReleaseTaskHelper ) . to receive ( :construct_release_task_description ) . with ( "Release notes content" , [ "1234567890" ] )
305306 expect ( Fastlane ::Helper ::AsanaHelper ) . to receive ( :move_tasks_to_section ) . with ( [ "1234567890" , "1234567890" ] , "987654321" , "secret-token" )
306307 expect ( Fastlane ::Helper ::AsanaHelper ) . to receive ( :tag_tasks ) . with ( "tag_id" , [ "1234567890" , "1234567890" ] , "secret-token" )
@@ -822,4 +823,39 @@ def sanitize_asana_html_notes(content)
822823 Fastlane ::Helper ::AsanaHelper . tag_tasks ( tag_id , task_ids , asana_access_token )
823824 end
824825 end
826+
827+ describe ".validate_task_accessible" do
828+ subject { Fastlane ::Helper ::AsanaHelper . validate_task_accessible ( task_id , asana_access_token ) }
829+
830+ let ( :task_id ) { "1234567890" }
831+ let ( :asana_access_token ) { "secret-token" }
832+
833+ before do
834+ @asana_client = double ( "Asana::Client" )
835+ allow ( Fastlane ::Helper ::AsanaHelper ) . to receive ( :make_asana_client ) . with ( asana_access_token ) . and_return ( @asana_client )
836+ allow ( Fastlane ::UI ) . to receive ( :important )
837+ end
838+
839+ context "when the task is accessible" do
840+ before do
841+ allow ( @asana_client ) . to receive_message_chain ( :tasks , :get_task ) . and_return ( double ( gid : task_id ) )
842+ end
843+
844+ it "returns true" do
845+ expect ( subject ) . to eq ( true )
846+ expect ( Fastlane ::UI ) . not_to have_received ( :important )
847+ end
848+ end
849+
850+ context "when the task is not accessible or fetching task data fails" do
851+ before do
852+ allow ( @asana_client ) . to receive_message_chain ( :tasks , :get_task ) . and_raise ( StandardError , "API Error" )
853+ end
854+
855+ it "returns false" do
856+ expect ( subject ) . to be false
857+ expect ( Fastlane ::UI ) . to have_received ( :important )
858+ end
859+ end
860+ end
825861end
0 commit comments