-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move upload_file_to_asana_task to helper
- Loading branch information
Showing
4 changed files
with
52 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,16 @@ | ||
describe Fastlane::Actions::AsanaUploadAction do | ||
describe "#run" do | ||
before do | ||
@task = double("task") | ||
@asana_client_tasks = double("asana_client_tasks") | ||
asana_client = double("asana_client") | ||
allow(Asana::Client).to receive(:new).and_return(asana_client) | ||
allow(asana_client).to receive(:tasks).and_return(@asana_client_tasks) | ||
it "calls helper" do | ||
task_id = "12345" | ||
file_name = "file.txt" | ||
asana_access_token = "secret-token" | ||
expect(Fastlane::Helper::DdgAppleAutomationHelper).to receive(:upload_file_to_asana_task) | ||
.with(task_id, file_name, asana_access_token) | ||
test_action(task_id, file_name, asana_access_token) | ||
end | ||
|
||
it "uploads a file successfully" do | ||
allow(@asana_client_tasks).to receive(:find_by_id).with("123").and_return(@task) | ||
allow(@task).to receive(:attach).with(filename: "path/to/file.txt", mime: "application/octet-stream") | ||
|
||
expect { test_action("123", "path/to/file.txt") }.not_to raise_error | ||
end | ||
|
||
it "shows error if failure" do | ||
allow(@asana_client_tasks).to receive(:find_by_id).with("123").and_return(@task) | ||
allow(@task).to receive(:attach).and_raise(StandardError.new("API Error")) | ||
|
||
expect(Fastlane::UI).to receive(:user_error!).with("Failed to upload file to Asana task: API Error") | ||
test_action("123", "path/to/file.txt") | ||
def test_action(task_id, file_name, asana_access_token) | ||
Fastlane::Actions::AsanaUploadAction.run(task_id: task_id, file_name: file_name, asana_access_token: asana_access_token) | ||
end | ||
end | ||
|
||
def test_action(task_id, file_name) | ||
Fastlane::Actions::AsanaUploadAction.run(task_id: task_id, | ||
file_name: file_name) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters