summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-03-13 09:42:07 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-03-13 09:42:07 +0200
commit45adf107b4cd8fffc2cc2eed359412b59e962bf0 (patch)
tree6100f7a7d40d918f86e1da14e4b4a48547ba1e03
parent9ce1fbc7812a23b6bd6e9e1993e4c55b93c610e3 (diff)
downloadgitlab-ci-45adf107b4cd8fffc2cc2eed359412b59e962bf0.tar.gz
fix build. Use frozen version of tested repo
-rw-r--r--db/schema.rb6
-rw-r--r--db/seeds.rb29
-rw-r--r--spec/factories/projects.rb14
-rw-r--r--spec/models/project_spec.rb4
-rw-r--r--spec/six.tar.gzbin0 -> 61937 bytes
-rw-r--r--spec/spec_helper.rb7
6 files changed, 37 insertions, 23 deletions
diff --git a/db/schema.rb b/db/schema.rb
index 299cb2b..9d60339 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -18,9 +18,9 @@ ActiveRecord::Schema.define(:version => 20130129121754) do
t.string "ref"
t.string "status"
t.datetime "finished_at"
- t.text "trace"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.text "trace", :limit => 2147483647
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
t.string "sha"
t.datetime "started_at"
t.string "tmp_file"
diff --git a/db/seeds.rb b/db/seeds.rb
index eae3609..f5cb35f 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -1,3 +1,5 @@
+require 'fileutils'
+
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
User.create(
@@ -7,9 +9,32 @@ User.create(
)
+if %w(development test).include?(Rails.env)
+ print "Unpacking seed repository..."
+
+ SEED_REPO = 'six.tar.gz'
+ REPO_PATH = Rails.root.join('tmp', 'repositories')
+
+ # Make whatever directories we need to make
+ FileUtils.mkdir_p(REPO_PATH)
+
+ # Copy the archive to the repo path
+ FileUtils.cp(Rails.root.join('spec', SEED_REPO), REPO_PATH)
+
+ # chdir to the repo path
+ FileUtils.cd(REPO_PATH) do
+ # Extract the archive
+ `tar -xf #{SEED_REPO}`
+
+ # Remove the copy
+ FileUtils.rm(SEED_REPO)
+ end
+
+ puts ' done.'
+end
+
if Rails.env == 'development'
- `rm -rf #{Rails.root.join('tmp', 'test_repo')}`
- `cd #{Rails.root.join('tmp')} && git clone https://github.com/randx/six.git test_repo`
+ puts 'Creating projets with builds '
project = FactoryGirl.create :project,
name: "Six",
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb
index e1491ae..87ecd5b 100644
--- a/spec/factories/projects.rb
+++ b/spec/factories/projects.rb
@@ -1,18 +1,14 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
- factory :project do
- name Faker::Name.name
- token 'iPWx6WM4lhHNedGfBpPJNP'
- default_ref 'master'
- path Rails.root.join('tmp', 'test_repo').to_s
- scripts 'ls'
- end
-
factory :project_without_token, class: Project do
name Faker::Name.name
default_ref 'master'
- path Rails.root.join('tmp', 'test_repo').to_s
+ path Rails.root.join('tmp', 'repositories', 'six').to_s
scripts 'ls'
+
+ factory :project do
+ token 'iPWx6WM4lhHNedGfBpPJNP'
+ end
end
end
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 60a6076..f7fa123 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -6,7 +6,7 @@ describe Project do
it { should have_many(:builds) }
describe :path do
- it { should allow_value(Rails.root.join('tmp', 'test_repo')).for(:path) }
+ it { should allow_value(Rails.root.join('tmp', 'repositories', 'six')).for(:path) }
it { should_not allow_value('/tmp').for(:path) }
end
@@ -48,7 +48,7 @@ describe Project do
it { project.last_build.should be_kind_of(Build) }
it { project.human_status.should == 'pending' }
it { project.status_image.should == 'running.png' }
- it { project.last_commit.sha.should == 'a26f8df380e56dc79cd74087c8ed4f031eef0460' }
+ it { project.last_commit.sha.should == '1c8a9df454ef68c22c2a33cca8232bb50849e5c5' }
end
end
end
diff --git a/spec/six.tar.gz b/spec/six.tar.gz
new file mode 100644
index 0000000..80a8c66
--- /dev/null
+++ b/spec/six.tar.gz
Binary files differ
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index b93f0a6..1e34e51 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -9,13 +9,6 @@ require 'sidekiq/testing/inline'
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
-
-test_repo_path = Rails.root.join('tmp', 'test_repo')
-
-unless File.exists?(test_repo_path)
- `git clone https://github.com/randx/six.git #{test_repo_path}`
-end
-
RSpec.configure do |config|
config.include LoginHelpers, type: :request