2012-10-09 04:14:17 -04:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: events
|
|
|
|
#
|
2012-11-19 13:24:05 -05:00
|
|
|
# id :integer not null, primary key
|
2012-10-09 04:14:17 -04:00
|
|
|
# target_type :string(255)
|
|
|
|
# target_id :integer
|
|
|
|
# title :string(255)
|
|
|
|
# data :text
|
|
|
|
# project_id :integer
|
2014-04-09 08:05:03 -04:00
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
2012-10-09 04:14:17 -04:00
|
|
|
# action :integer
|
|
|
|
# author_id :integer
|
|
|
|
#
|
|
|
|
|
2012-02-28 08:09:23 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Event do
|
2012-02-28 09:01:14 -05:00
|
|
|
describe "Associations" do
|
|
|
|
it { should belong_to(:project) }
|
2012-08-29 11:36:02 -04:00
|
|
|
it { should belong_to(:target) }
|
2012-02-28 09:01:14 -05:00
|
|
|
end
|
|
|
|
|
2012-03-28 15:53:45 -04: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-09-14 18:00:59 -04:00
|
|
|
describe "Push event" do
|
|
|
|
before do
|
2012-11-05 22:31:55 -05:00
|
|
|
project = create(:project)
|
2012-03-28 15:53:45 -04:00
|
|
|
@user = project.owner
|
|
|
|
|
2012-09-14 18:00:59 -04:00
|
|
|
data = {
|
2012-08-10 18:07:50 -04:00
|
|
|
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
|
2012-03-28 15:53:45 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@event = Event.create(
|
2012-08-10 18:07:50 -04:00
|
|
|
project: project,
|
2013-02-13 06:48:16 -05:00
|
|
|
action: Event::PUSHED,
|
2012-08-10 18:07:50 -04:00
|
|
|
data: data,
|
|
|
|
author_id: @user.id
|
2012-03-28 15:53:45 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { @event.push?.should be_true }
|
2012-12-14 14:54:49 -05:00
|
|
|
it { @event.proper?.should be_true }
|
2012-03-28 15:53:45 -04:00
|
|
|
it { @event.new_branch?.should be_true }
|
2012-04-02 01:50:37 -04:00
|
|
|
it { @event.tag?.should be_false }
|
2012-03-28 15:53:45 -04:00
|
|
|
it { @event.branch_name.should == "master" }
|
|
|
|
it { @event.author.should == @user }
|
|
|
|
end
|
2012-02-28 08:09:23 -05:00
|
|
|
end
|