Skip to content

Commit

Permalink
Add git instances and files in the seeds.
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenk committed Apr 18, 2017
1 parent fbbb2a7 commit 6b8587b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ GEM
escape_utils (~> 1.1.0)
mime-types (>= 1.19)
rugged (>= 0.23.0b)
globalid (0.3.7)
activesupport (>= 4.1.0)
globalid (0.4.0)
activesupport (>= 4.2.0)
i18n (0.8.1)
interception (0.5)
json (2.0.4)
Expand Down
30 changes: 22 additions & 8 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
url_path_method = lambda do |resource|
V2::OrganizationsController.resource_url_path(resource)
end
Organization.new(name: 'All Users', url_path_method: url_path_method).save
Organization.new(name: 'Seed User Organization',
url_path_method: url_path_method).save
organization = Organization.first
User.all do |user|
organization.add_member(user)
Expand All @@ -28,11 +29,24 @@
end
owner_count = OrganizationalUnit.count
content_types = %w(ontology model specification mathematical)
(0..(2 * owner_count - 1)).each do |index|
Repository.new(owner: OrganizationalUnit.find(id: index % owner_count + 1),
name: "repo#{index}",
content_type: content_types[index % content_types.size],
public_access: true,
description: 'This is a dummy repository.',
url_path_method: url_path_method).save
(0..(2 * owner_count - 1)).each do |repo_index|
owner = OrganizationalUnit.find(id: repo_index % owner_count + 1)
repository =
RepositoryCompound.
new(owner: owner,
name: "repo#{repo_index}",
content_type: content_types[repo_index % content_types.size],
public_access: true,
description: 'This is a dummy repository.',
url_path_method: url_path_method)
repository.save

user = owner.is_a?(Organization) ? owner.members.first : owner
(1..5).each do |file_index|
path = "#{file_index}_test.txt"
path = "subdir_#{file_index}/#{path}" if file_index <= 2
Blob.new(repository: repository, user: user, branch: 'master', path: path,
content: "test file ##{file_index}", encoding: 'plain',
commit_message: "Add #{path}.").create
end
end

0 comments on commit 6b8587b

Please sign in to comment.