OSDN Git Service

fixtures added
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Sun, 4 Dec 2011 20:19:49 +0000 (22:19 +0200)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Sun, 4 Dec 2011 20:19:49 +0000 (22:19 +0200)
app/models/repository.rb
db/fixtures/development/001_admin.rb
db/fixtures/development/002_project.rb [new file with mode: 0644]
db/fixtures/development/003_users.rb [new file with mode: 0644]
db/fixtures/development/004_teams.rb [new file with mode: 0644]

index a3e2e1e..1a1c90a 100644 (file)
@@ -1,3 +1,5 @@
+require File.join(Rails.root, "lib", "gitlabhq", "git_host")
+
 class Repository
   attr_accessor :project
 
@@ -34,13 +36,13 @@ class Repository
   end
 
   def update_gitosis_project
-    GitProxy.system.new.configure do |c|
+    Gitlabhq::GitHost.system.new.configure do |c|
       c.update_project(path, project.gitosis_writers)
     end
   end
 
   def destroy_gitosis_project
-    GitProxy.system.new.configure do |c|
+    Gitlabhq::GitHost.system.new.configure do |c|
       c.destroy_project(@project)
     end
   end
index cfff6bf..c857f6b 100644 (file)
@@ -1,19 +1,21 @@
-admin = User.create(
-  :email => "admin@local.host",
-  :name => "Administrator",
-  :password => "5iveL!fe",
-  :password_confirmation => "5iveL!fe"
-)
+unless User.count > 0
+  admin = User.create(
+    :email => "admin@local.host",
+    :name => "Administrator",
+    :password => "5iveL!fe",
+    :password_confirmation => "5iveL!fe"
+  )
 
-admin.projects_limit = 10000
-admin.admin = true
-admin.save!
+  admin.projects_limit = 10000
+  admin.admin = true
+  admin.save!
 
-if admin.valid?
-puts %q[
-Administrator account created:
+  if admin.valid?
+    puts %q[
+    Administrator account created:
 
-login.........admin@local.host
-password......5iveL!fe
-]
+    login.........admin@local.host
+    password......5iveL!fe
+    ]
+  end
 end
diff --git a/db/fixtures/development/002_project.rb b/db/fixtures/development/002_project.rb
new file mode 100644 (file)
index 0000000..8eb99f2
--- /dev/null
@@ -0,0 +1,5 @@
+Project.seed(:id, [
+  { :id => 1, :name => "Gitlab HQ", :path => "gitlabhq", :code => "gitlabhq", :owner_id => 1 },
+  { :id => 2, :name => "Diaspora", :path => "diaspora", :code => "diaspora", :owner_id => 1 },
+  { :id => 3, :name => "Ruby on Rails", :path => "ruby_on_rails", :code => "ruby_on_rails", :owner_id => 1 }
+])
diff --git a/db/fixtures/development/003_users.rb b/db/fixtures/development/003_users.rb
new file mode 100644 (file)
index 0000000..309eb90
--- /dev/null
@@ -0,0 +1,11 @@
+User.seed(:id, [
+  { :id => 2, :name => Faker::Internet.user_name, :email => Faker::Internet.email},
+  { :id => 3, :name => Faker::Internet.user_name, :email => Faker::Internet.email},
+  { :id => 4, :name => Faker::Internet.user_name, :email => Faker::Internet.email},
+  { :id => 5, :name => Faker::Internet.user_name, :email => Faker::Internet.email},
+  { :id => 6, :name => Faker::Internet.user_name, :email => Faker::Internet.email},
+  { :id => 7, :name => Faker::Internet.user_name, :email => Faker::Internet.email},
+  { :id => 8, :name => Faker::Internet.user_name, :email => Faker::Internet.email},
+  { :id => 9, :name => Faker::Internet.user_name, :email => Faker::Internet.email}
+])
+
diff --git a/db/fixtures/development/004_teams.rb b/db/fixtures/development/004_teams.rb
new file mode 100644 (file)
index 0000000..69742e4
--- /dev/null
@@ -0,0 +1,21 @@
+UsersProject.seed(:id, [
+  { :id => 1,  :project_id => 1, :user_id => 1},
+  { :id => 2,  :project_id => 1, :user_id => 2},
+  { :id => 3,  :project_id => 1, :user_id => 3},
+  { :id => 4,  :project_id => 1, :user_id => 4},
+  { :id => 5,  :project_id => 1, :user_id => 5},
+
+  { :id => 6,  :project_id => 2, :user_id => 1},
+  { :id => 7,  :project_id => 2, :user_id => 2},
+  { :id => 8,  :project_id => 2, :user_id => 3},
+  { :id => 9,  :project_id => 2, :user_id => 4},
+  { :id => 11, :project_id => 2, :user_id => 5},
+
+  { :id => 12, :project_id => 3, :user_id => 1},
+  { :id => 13, :project_id => 3, :user_id => 2},
+  { :id => 14, :project_id => 3, :user_id => 3},
+  { :id => 15, :project_id => 3, :user_id => 4},
+  { :id => 16, :project_id => 3, :user_id => 5}
+])
+
+