Merge branch 'master' into fixes/api
This commit is contained in:
commit
ac4a09e9cc
94 changed files with 935 additions and 731 deletions
|
@ -32,6 +32,12 @@ describe MergeRequest do
|
|||
it { should_not allow_mass_assignment_of(:project_id) }
|
||||
end
|
||||
|
||||
describe "Respond to" do
|
||||
it { should respond_to(:unchecked?) }
|
||||
it { should respond_to(:can_be_merged?) }
|
||||
it { should respond_to(:cannot_be_merged?) }
|
||||
end
|
||||
|
||||
describe 'modules' do
|
||||
it { should include_module(Issuable) }
|
||||
end
|
||||
|
|
|
@ -1,128 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Project, "Hooks" do
|
||||
let(:project) { create(:project) }
|
||||
|
||||
before do
|
||||
@key = create(:key, user: project.owner)
|
||||
@user = @key.user
|
||||
@key_id = @key.identifier
|
||||
end
|
||||
|
||||
describe "Post Receive Event" do
|
||||
it "should create push event" do
|
||||
oldrev, newrev, ref = '00000000000000000000000000000000', 'newrev', 'refs/heads/master'
|
||||
data = project.post_receive_data(oldrev, newrev, ref, @user)
|
||||
|
||||
project.observe_push(data)
|
||||
event = Event.last
|
||||
|
||||
event.should_not be_nil
|
||||
event.project.should == project
|
||||
event.action.should == Event::PUSHED
|
||||
event.data.should == data
|
||||
end
|
||||
end
|
||||
|
||||
describe "Project hooks" do
|
||||
context "with no web hooks" do
|
||||
it "raises no errors" do
|
||||
lambda {
|
||||
project.execute_hooks({})
|
||||
}.should_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
context "with web hooks" do
|
||||
before do
|
||||
@project_hook = create(:project_hook)
|
||||
@project_hook_2 = create(:project_hook)
|
||||
project.hooks << [@project_hook, @project_hook_2]
|
||||
|
||||
stub_request(:post, @project_hook.url)
|
||||
stub_request(:post, @project_hook_2.url)
|
||||
end
|
||||
|
||||
it "executes multiple web hook" do
|
||||
@project_hook.should_receive(:async_execute).once
|
||||
@project_hook_2.should_receive(:async_execute).once
|
||||
|
||||
project.trigger_post_receive('oldrev', 'newrev', 'refs/heads/master', @user)
|
||||
end
|
||||
end
|
||||
|
||||
context "does not execute web hooks" do
|
||||
before do
|
||||
@project_hook = create(:project_hook)
|
||||
project.hooks << [@project_hook]
|
||||
end
|
||||
|
||||
it "when pushing a branch for the first time" do
|
||||
@project_hook.should_not_receive(:execute)
|
||||
project.trigger_post_receive('00000000000000000000000000000000', 'newrev', 'refs/heads/master', @user)
|
||||
end
|
||||
|
||||
it "when pushing tags" do
|
||||
@project_hook.should_not_receive(:execute)
|
||||
project.trigger_post_receive('oldrev', 'newrev', 'refs/tags/v1.0.0', @user)
|
||||
end
|
||||
end
|
||||
|
||||
context "when pushing new branches" do
|
||||
|
||||
end
|
||||
|
||||
context "when gathering commit data" do
|
||||
before do
|
||||
@oldrev, @newrev, @ref = project.repository.fresh_commits(2).last.sha,
|
||||
project.repository.fresh_commits(2).first.sha, 'refs/heads/master'
|
||||
@commit = project.repository.fresh_commits(2).first
|
||||
|
||||
# Fill nil/empty attributes
|
||||
project.description = "This is a description"
|
||||
|
||||
@data = project.post_receive_data(@oldrev, @newrev, @ref, @user)
|
||||
end
|
||||
|
||||
subject { @data }
|
||||
|
||||
it { should include(before: @oldrev) }
|
||||
it { should include(after: @newrev) }
|
||||
it { should include(ref: @ref) }
|
||||
it { should include(user_id: project.owner.id) }
|
||||
it { should include(user_name: project.owner.name) }
|
||||
|
||||
context "with repository data" do
|
||||
subject { @data[:repository] }
|
||||
|
||||
it { should include(name: project.name) }
|
||||
it { should include(url: project.url_to_repo) }
|
||||
it { should include(description: project.description) }
|
||||
it { should include(homepage: project.web_url) }
|
||||
end
|
||||
|
||||
context "with commits" do
|
||||
subject { @data[:commits] }
|
||||
|
||||
it { should be_an(Array) }
|
||||
it { should have(1).element }
|
||||
|
||||
context "the commit" do
|
||||
subject { @data[:commits].first }
|
||||
|
||||
it { should include(id: @commit.id) }
|
||||
it { should include(message: @commit.safe_message) }
|
||||
it { should include(timestamp: @commit.date.xmlschema) }
|
||||
it { should include(url: "#{Gitlab.config.gitlab.url}/#{project.code}/commit/#{@commit.id}") }
|
||||
|
||||
context "with a author" do
|
||||
subject { @data[:commits].first[:author] }
|
||||
|
||||
it { should include(name: @commit.author_name) }
|
||||
it { should include(email: @commit.author_email) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -72,11 +72,8 @@ describe Project do
|
|||
it { should respond_to(:url_to_repo) }
|
||||
it { should respond_to(:repo_exists?) }
|
||||
it { should respond_to(:satellite) }
|
||||
it { should respond_to(:observe_push) }
|
||||
it { should respond_to(:update_merge_requests) }
|
||||
it { should respond_to(:execute_hooks) }
|
||||
it { should respond_to(:post_receive_data) }
|
||||
it { should respond_to(:trigger_post_receive) }
|
||||
it { should respond_to(:transfer) }
|
||||
it { should respond_to(:name_with_namespace) }
|
||||
it { should respond_to(:namespace_owner) }
|
||||
|
|
|
@ -10,9 +10,6 @@ describe ProjectTeam do
|
|||
it { should respond_to(:masters) }
|
||||
it { should respond_to(:reporters) }
|
||||
it { should respond_to(:guests) }
|
||||
it { should respond_to(:repository_writers) }
|
||||
it { should respond_to(:repository_masters) }
|
||||
it { should respond_to(:repository_readers) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -69,28 +69,10 @@ describe User do
|
|||
|
||||
describe "Respond to" do
|
||||
it { should respond_to(:is_admin?) }
|
||||
it { should respond_to(:identifier) }
|
||||
it { should respond_to(:name) }
|
||||
it { should respond_to(:private_token) }
|
||||
end
|
||||
|
||||
describe '#identifier' do
|
||||
it "should return valid identifier" do
|
||||
user = build(:user, email: "test@mail.com")
|
||||
user.identifier.should == "test_mail_com"
|
||||
end
|
||||
|
||||
it "should return identifier without + sign" do
|
||||
user = build(:user, email: "test+foo@mail.com")
|
||||
user.identifier.should == "test_foo_mail_com"
|
||||
end
|
||||
|
||||
it "should conform to Gitolite's required identifier pattern" do
|
||||
user = build(:user, email: "_test@example.com")
|
||||
user.identifier.should == 'test_example_com'
|
||||
end
|
||||
end
|
||||
|
||||
describe '#generate_password' do
|
||||
it "should execute callback when force_random_password specified" do
|
||||
user = build(:user, force_random_password: true)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue