2012-02-28 14:09:23 +01:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: events
|
|
|
|
#
|
2012-06-26 20:23:09 +02:00
|
|
|
# id :integer(4) not null, primary key
|
2012-02-28 15:01:14 +01:00
|
|
|
# target_type :string(255)
|
2012-06-26 20:23:09 +02:00
|
|
|
# target_id :integer(4)
|
2012-02-28 15:01:14 +01:00
|
|
|
# title :string(255)
|
|
|
|
# data :text
|
2012-06-26 20:23:09 +02:00
|
|
|
# project_id :integer(4)
|
2012-02-28 15:01:14 +01:00
|
|
|
# created_at :datetime not null
|
|
|
|
# updated_at :datetime not null
|
2012-06-26 20:23:09 +02:00
|
|
|
# action :integer(4)
|
|
|
|
# author_id :integer(4)
|
2012-02-28 14:09:23 +01:00
|
|
|
#
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Event do
|
2012-02-28 15:01:14 +01:00
|
|
|
describe "Associations" do
|
|
|
|
it { should belong_to(:project) }
|
|
|
|
end
|
|
|
|
|
2012-03-28 21:53:45 +02:00
|
|
|
describe "Respond to" do
|
|
|
|
it { should respond_to(:author_name) }
|
|
|
|
it { should respond_to(:author_email) }
|
|
|
|
it { should respond_to(:issue_title) }
|
|
|
|
it { should respond_to(:merge_request_title) }
|
|
|
|
it { should respond_to(:commits) }
|
|
|
|
end
|
|
|
|
|
2012-02-28 15:01:14 +01:00
|
|
|
describe "Creation" do
|
|
|
|
before do
|
|
|
|
@event = Factory :event
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should create a valid event" do
|
|
|
|
@event.should be_valid
|
|
|
|
end
|
|
|
|
end
|
2012-03-28 21:53:45 +02:00
|
|
|
|
|
|
|
describe "Push event" do
|
|
|
|
before do
|
|
|
|
project = Factory :project
|
|
|
|
@user = project.owner
|
|
|
|
|
|
|
|
data = {
|
|
|
|
:before => "0000000000000000000000000000000000000000",
|
|
|
|
:after => "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e",
|
|
|
|
:ref => "refs/heads/master",
|
|
|
|
:user_id => @user.id,
|
|
|
|
:user_name => @user.name,
|
|
|
|
:repository => {
|
|
|
|
:name => project.name,
|
|
|
|
:url => "localhost/rubinius",
|
|
|
|
:description => "",
|
|
|
|
:homepage => "localhost/rubinius",
|
|
|
|
:private => true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@event = Event.create(
|
|
|
|
:project => project,
|
|
|
|
:action => Event::Pushed,
|
|
|
|
:data => data,
|
|
|
|
:author_id => @user.id
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { @event.push?.should be_true }
|
|
|
|
it { @event.allowed?.should be_true }
|
|
|
|
it { @event.new_branch?.should be_true }
|
2012-04-02 07:50:37 +02:00
|
|
|
it { @event.tag?.should be_false }
|
2012-03-28 21:53:45 +02:00
|
|
|
it { @event.branch_name.should == "master" }
|
|
|
|
it { @event.author.should == @user }
|
|
|
|
end
|
2012-02-28 14:09:23 +01:00
|
|
|
end
|