Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reviewing uncovered lines #1772

Merged
merged 3 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions app/models/annotations/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,6 @@ def get_file_from_uri(params)
params
end

def existing_files
self.first_response_obj&.load&.file.to_a
end

def add_files(new_files)
self.file = [self.existing_files].flatten.reject{ |f| f.blank? }.concat(new_files)
self.response = '{}'
end

def remove_files(filenames)
self.file = [existing_files].flatten.reject{ |f| f.blank? || filenames.include?(f.to_s.split('/').last) }
self.response = '{}'
end

def first_response_obj
return @response if @response
responses = self.responses
Expand Down
10 changes: 10 additions & 0 deletions test/controllers/graphql_controller_7_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,16 @@ def teardown
assert_equal [pm.id], JSON.parse(@response.body)['data']['project_medias']['edges'].collect{ |x| x['node']['dbid'] }
end

test "should update task files" do
u = create_user is_admin: true
t = create_task
f = Rack::Test::UploadedFile.new(File.join(Rails.root, 'test', 'data', 'rails.png'), 'image/png')
authenticate_with_user(u)
query = 'mutation { updateTask(input: { clientMutationId: "1", id: "' + t.graphql_id + '" }) { task { id } } }'
post :create, params: { query: query, team: t.slug, file: { '0' => f } }
assert_response :success
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caiosba when you have some time:
I know we talked about this yesterday, but why is this specific test needed? I'm not sure, but I think we talked about the uploading of files in the tipline, there was nothing that was needed regarding that, or are they related?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vasconsaurus , that part of the code is about uploading multiple files when calling a mutation, so the mutation itself doesn't really matter... since the test is about uploading files, I used a simpler mutation. In practice, yes, we use it in the application for tipline images and annotations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gracias ❤️

protected

def assert_error_message(expected)
Expand Down
4 changes: 2 additions & 2 deletions test/models/project_media_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def perform(id)
pm = create_project_media team: t, set_tasks_responses: { 'upload_a_file' => url }
end
task = pm.annotations('task').last
assert task.existing_files.size > 0
assert task.first_response_obj&.load&.file.to_a.size > 0
end
end

Expand Down Expand Up @@ -463,4 +463,4 @@ def perform(id)
assert_equal 2, ProjectMedia.where(id: [pm_s.id, pm_t.id], archived: CheckArchivedFlags::FlagCodes::NONE).count
assert_not_nil Relationship.where(id: r.id).last
end
end
end
Loading