[refs #90] some tests and questions

This commit is contained in:
Alexander Machehin 2012-04-20 01:08:33 +06:00
parent 58776a6e9e
commit fda1a847f5
20 changed files with 136 additions and 98 deletions

View File

@ -14,7 +14,7 @@ class PullRequest < Issue
end
event :block do
transition [:open, :ready] => :block
transition [:open, :ready] => :blocked
end
event :merging do
@ -35,7 +35,7 @@ class PullRequest < Issue
end
def check
if ret = merge
if ret = merge #FIXME already up-to-date...
system("cd #{path} && git reset --hard HEAD^") # remove merge commit
ready
else
@ -76,14 +76,11 @@ class PullRequest < Issue
unless git.exist?
FileUtils.mkdir_p(path)
Dir.chdir(path) do
system("git clone --local --no-hardlinks #{project.path} #{path}")
end
else
Dir.chdir(path) do
[data[:base_branch], data[:head_branch]].each do |branch|
system "git checkout #{branch} && git pull origin #{branch}"
end
system("git clone --local --no-hardlinks #{project.path} #{path}")
end
Dir.chdir(path) do
[data[:base_branch], data[:head_branch]].each do |branch|
system "git checkout #{branch} && git pull origin #{branch}"
end
end
# TODO catch errors

View File

@ -17,14 +17,14 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
t.integer "user_id", :null => false
t.string "kind"
t.text "data"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "arches", :force => true do |t|
t.string "name", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "arches", ["name"], :name => "index_arches_on_name", :unique => true
@ -33,8 +33,8 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
t.integer "user_id"
t.string "provider"
t.string "uid"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "authentications", ["provider", "uid"], :name => "index_authentications_on_provider_and_uid", :unique => true
@ -45,8 +45,8 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
t.integer "level"
t.integer "status"
t.integer "build_list_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "version"
end
@ -60,8 +60,8 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
t.integer "project_id"
t.integer "arch_id"
t.datetime "notified_at"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "is_circle", :default => false
t.text "additional_repos"
t.string "name"
@ -87,8 +87,8 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
t.string "commentable_type"
t.integer "user_id"
t.text "body"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.decimal "commentable_id", :precision => 50, :scale => 0
t.integer "project_id"
end
@ -102,8 +102,8 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
t.datetime "locked_at"
t.datetime "failed_at"
t.string "locked_by"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "queue", :default => "default"
end
@ -121,14 +121,14 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
t.string "controller"
t.string "action"
t.text "message"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "groups", :force => true do |t|
t.integer "owner_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "uname"
t.integer "own_projects_count", :default => 0, :null => false
t.text "description"
@ -141,11 +141,14 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
t.string "title"
t.text "body"
t.string "status", :default => "open"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "user_id"
t.datetime "closed_at"
t.integer "closed_by"
t.string "type"
t.string "state"
t.text "data", :default => "0", :null => false
end
add_index "issues", ["project_id", "serial_id"], :name => "index_issues_on_project_id_and_serial_id", :unique => true
@ -173,8 +176,8 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
t.string "description"
t.string "name", :null => false
t.integer "parent_platform_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "released", :default => false, :null => false
t.integer "owner_id"
t.string "owner_type"
@ -189,8 +192,8 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
t.integer "platform_id"
t.string "login"
t.string "password"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "user_id"
end
@ -198,8 +201,8 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
t.integer "product_id"
t.integer "status", :default => 2, :null => false
t.datetime "notified_at"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "product_build_lists", ["product_id"], :name => "index_product_build_lists_on_product_id"
@ -207,8 +210,8 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
create_table "products", :force => true do |t|
t.string "name", :null => false
t.integer "platform_id", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.text "build_script"
t.text "counter"
t.text "ks"
@ -227,8 +230,8 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
t.string "name"
t.string "version"
t.datetime "file_mtime"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "platform_id"
end
@ -237,14 +240,14 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
create_table "project_to_repositories", :force => true do |t|
t.integer "project_id"
t.integer "repository_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "projects", :force => true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "owner_id"
t.string "owner_type"
t.string "visibility", :default => "open"
@ -262,6 +265,8 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
t.integer "build_count", :default => 0, :null => false
end
add_index "projects", ["owner_id"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true, :case_sensitive => false
create_table "register_requests", :force => true do |t|
t.string "name"
t.string "email"
@ -282,16 +287,16 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
t.string "object_type"
t.integer "target_id"
t.string "target_type"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "role"
end
create_table "repositories", :force => true do |t|
t.string "description", :null => false
t.integer "platform_id", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "name", :null => false
end
@ -302,8 +307,8 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
t.boolean "new_comment_reply", :default => true
t.boolean "new_issue", :default => true
t.boolean "issue_assign", :default => true
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "new_comment_commit_owner", :default => true
t.boolean "new_comment_commit_repo_owner", :default => true
t.boolean "new_comment_commit_commentor", :default => true
@ -312,8 +317,8 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
create_table "subscribes", :force => true do |t|
t.string "subscribeable_type"
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "status", :default => true
t.integer "project_id"
t.decimal "subscribeable_id", :precision => 50, :scale => 0
@ -321,21 +326,21 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
create_table "users", :force => true do |t|
t.string "name"
t.string "email", :default => "", :null => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false
t.string "password_salt", :default => "", :null => false
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.text "ssh_key"
t.string "uname"
t.string "role"
t.string "language", :default => "en"
t.string "language", :default => "en"
t.integer "own_projects_count", :default => 0, :null => false
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.integer "own_projects_count", :default => 0, :null => false
t.datetime "reset_password_sent_at"
t.text "professional_experience"
t.string "site"
t.string "company"
@ -344,7 +349,7 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
t.string "avatar_content_type"
t.integer "avatar_file_size"
t.datetime "avatar_updated_at"
t.integer "failed_attempts", :default => 0
t.integer "failed_attempts", :default => 0
t.string "unlock_token"
t.datetime "locked_at"
t.string "authentication_token"

11
lib/tasks/reset_db.rake Normal file
View File

@ -0,0 +1,11 @@
namespace :db do
desc "Drop, create, migrate then seed the database"
task :reset_db => :environment do
Rake::Task['db:drop'].invoke
Rake::Task['db:create'].invoke
Rake::Task['db:migrate'].invoke
Rake::Task['db:fixtures:load'].invoke
Rake::Task['db:seed'].invoke
end
end

View File

@ -298,7 +298,8 @@ describe Comment do
context 'for committer' do
it 'should send an e-mail' do
@simple.update_attribute :email, 'code@tpope.net'
@simple.subscribes.destroy_all
@simple.update_attribute :email, 'test@test.test'
comment = create_comment(@user)
ActionMailer::Base.deliveries.count.should == 1
ActionMailer::Base.deliveries.last.to.include?(@simple.email).should == true
@ -306,21 +307,22 @@ describe Comment do
it 'should send a one e-mail when subscribed to commit' do
Subscribe.subscribe_to_commit @subscribe_params.merge(:user_id => @simple.id)
@simple.update_attribute :email, 'code@tpope.net'
@simple.update_attribute :email, 'test@test.test'
comment = create_comment(@user)
ActionMailer::Base.deliveries.count.should == 1
ActionMailer::Base.deliveries.last.to.include?(@simple.email).should == true
end
it 'should not send an e-mail for own comment' do
@simple.update_attribute :email, 'code@tpope.net'
@simple.subscribes.destroy_all
@simple.update_attribute :email, 'test@test.test'
comment = create_comment(@simple)
ActionMailer::Base.deliveries.count.should == 0
end
it 'should not send an e-mail if global notify off' do
@project.owner.notifier.update_attribute :can_notify, false
@simple.update_attribute :email, 'code@tpope.net'
@simple.update_attribute :email, 'test@test.test'
@simple.notifier.update_attribute :can_notify, false
comment = create_comment(@user)
ActionMailer::Base.deliveries.count.should == 0
@ -329,7 +331,7 @@ describe Comment do
it 'should not send an e-mail if notify for my commits off' do
Comment.destroy_all
@simple.notifier.update_attribute :new_comment_commit_owner, false
@simple.update_attribute :email, 'code@tpope.net'
@simple.update_attribute :email, 'test@test.test'
comment = create_comment(@user)
ActionMailer::Base.deliveries.count.should == 0
end

View File

@ -1,20 +1,48 @@
# -*- encoding : utf-8 -*-
require 'spec_helper'
def set_data_for_pull
@ability = Ability.new(@user)
@project = FactoryGirl.create(:project, :owner => @user)
%x(cp -Rf #{Rails.root}/spec/tests.git/* #{@project.path}) # maybe FIXME ?
@clone_path = File.join(APP_CONFIG['root_path'], 'repo_clone', @project.id.to_s)
FileUtils.mkdir_p(@clone_path)
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
end
describe PullRequest do
context 'for owner user' do
before (:all) do
stub_rsync_methods
@user = FactoryGirl.create(:user)
set_data_for_pull
@pull = @project.pull_requests.new(:title => 'test', :body => 'testing')
@pull.user = @user
@pull.data = {:base_branch => 'master', :head_branch => 'non_conflicts'}
@pull.save
end
#~ context 'when create with same owner that platform' do
#~ before (:each) do
#~ stub_rsync_methods
#~ @platform = FactoryGirl.create(:platform)
#~ @params = {:name => 'tst_platform', :description => 'test platform'}
#~ end
it 'master should can be merged with non_conflicts branch' do
@pull.check
@pull.state.should == 'ready'
end
#~ it 'it should increase Repository.count by 1' do
#~ rep = Repository.create(@params) {|r| r.platform = @platform}
#~ @platform.repositories.count.should eql(1)
#~ end
#~ end
it 'master should not be merged with conflicts branch' do
@pull.data[:head_branch] = 'conflicts'
@pull.check
@pull.state.should == 'blocked'
end
it 'should not be merged when already up-to-date branches' do
@pull.data[:head_branch] = 'master'
@pull.check
@pull.state.should == 'blocked' # FIXME
end
end
before(:all) do
stub_rsync_methods

View File

@ -1 +1 @@
bdc8b580b5b583aeb43efb19aac2ab8ce5566dff
ref: refs/heads/master

View File

@ -1,11 +1,4 @@
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git://github.com/tpope/vim-ragtag.git
[branch "master"]
remote = origin
merge = refs/heads/master
bare = true

Binary file not shown.

5
spec/tests.git/info/refs Normal file
View File

@ -0,0 +1,5 @@
5dc2326fab1022c9c35b27d09c62a73216fdff5e refs/heads/conficts
45d6bc11f4de8546ccbef16fdd3acf48fe0b411c refs/heads/conflicts
2babca2e12fe8e5f0ea95e8547a9ce20c322cb79 refs/heads/master
5c2312c4054bae9c1419dbec8633eda29f7c0731 refs/heads/non_conflicts
00a2f9225dcc5807b9eb46f1bcfc56ee939e595f refs/heads/not_conflicts

View File

@ -1,2 +0,0 @@
0000000000000000000000000000000000000000 bdc8b580b5b583aeb43efb19aac2ab8ce5566dff Alexander <avm@avm-work.(none)> 1325695134 +0600 clone: from git://github.com/tpope/vim-ragtag.git
bdc8b580b5b583aeb43efb19aac2ab8ce5566dff bdc8b580b5b583aeb43efb19aac2ab8ce5566dff Alexander <avm@avm-work.(none)> 1325695134 +0600 checkout: moving from master to bdc8b580b5b583aeb43efb19aac2ab8ce5566dff

View File

@ -1 +0,0 @@
0000000000000000000000000000000000000000 bdc8b580b5b583aeb43efb19aac2ab8ce5566dff Alexander <avm@avm-work.(none)> 1325695134 +0600 clone: from git://github.com/tpope/vim-ragtag.git

View File

@ -0,0 +1,2 @@
x<01>خM
آ0<10>aط9إٌ<05>L2<4C><11>2I&ظE[iك<69>m=<3D><>gّء _]هy@<40><><EFBFBD><EFBFBD><EFBFBD>-\Z<>E<EFBFBD>+<2B>و<EFBFBD>3­C$ٌحني+:<3A><>M<EFBFBD>ات,<14>('ق<>)<29><>=<3D>ظ|!lD<6C><44> hل3^ًC<><01>سهةٍلض9<D8B6>\Ftpإ<70>hيُضذ؟3-0ث~ن \>y

View File

@ -0,0 +1,2 @@
P pack-09ad35f874bea18d5f133a59210e4f80a1e81c17.pack

View File

@ -1,5 +1,3 @@
# pack-refs with: peeled
30aefeac002db3ec08ff278bd76290645469611e refs/tags/v2.0
^644c62ad7bc7d9a4a5f19f5e8c41ef910782178b
235e4467107467feacc50553bbeda15e9bf99f57 refs/tags/v1.11
bdc8b580b5b583aeb43efb19aac2ab8ce5566dff refs/remotes/origin/master
45d6bc11f4de8546ccbef16fdd3acf48fe0b411c refs/heads/conflicts
2babca2e12fe8e5f0ea95e8547a9ce20c322cb79 refs/heads/master
5c2312c4054bae9c1419dbec8633eda29f7c0731 refs/heads/non_conflicts

View File

@ -1 +0,0 @@
bdc8b580b5b583aeb43efb19aac2ab8ce5566dff

View File

@ -1 +0,0 @@
ref: refs/remotes/origin/master