Skip to content

Commit

Permalink
Adding missing test and deleting useless lines
Browse files Browse the repository at this point in the history
  • Loading branch information
caiosba committed Jan 5, 2024
1 parent 6d60fb7 commit 4361b3c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
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

protected

def assert_error_message(expected)
Expand Down

0 comments on commit 4361b3c

Please sign in to comment.