Skip to content

Commit

Permalink
Remove unecessary array from Project#expand_all_repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
vpereira committed Nov 5, 2019
1 parent 5aa49d0 commit a77aaea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/api/app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -766,11 +766,7 @@ def find_package(package_name, check_update_project = nil, processed = {})
end

def expand_all_repositories
all_repositories = repositories.to_a
repositories.each do |repository|
all_repositories.concat(repository.expand_all_repositories)
end
all_repositories.uniq
repositories.collect(&:expand_all_repositories).flatten.uniq
end

def expand_linking_to
Expand Down
9 changes: 9 additions & 0 deletions src/api/spec/models/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -735,4 +735,13 @@ def reset_project_in_backend
it { expect(subject).not_to be_empty }
it { expect(subject).to include(link_target_project) }
end

describe '#expand_all_repositories' do
let!(:project) { create(:project_with_repository, name: 'super_project') }

subject { project.expand_all_repositories }

it { expect(subject).not_to be_empty }
it { expect(subject).to include(project.repositories.first) }
end
end

0 comments on commit a77aaea

Please sign in to comment.