gitlabhq/spec/models/event_spec.rb

90 lines
2.1 KiB
Ruby
Raw Normal View History

2012-10-09 10:14:17 +02:00
# == Schema Information
#
# Table name: events
#
2012-11-19 19:24:05 +01:00
# id :integer not null, primary key
2012-10-09 10:14:17 +02:00
# target_type :string(255)
# target_id :integer
# title :string(255)
# data :text
# project_id :integer
2012-11-19 19:24:05 +01:00
# created_at :datetime not null
# updated_at :datetime not null
2012-10-09 10:14:17 +02:00
# action :integer
# author_id :integer
#
2012-02-28 14:09:23 +01:00
require 'spec_helper'
describe Event do
describe "Associations" do
it { should belong_to(:project) }
it { should belong_to(:target) }
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-09-15 00:00:59 +02:00
describe "Push event" do
before do
project = create(:project)
2012-03-28 21:53:45 +02:00
@user = project.owner
2012-09-15 00:00:59 +02:00
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
2012-03-28 21:53:45 +02:00
}
}
@event = Event.create(
project: project,
action: Event::Pushed,
data: data,
author_id: @user.id
2012-03-28 21:53:45 +02:00
)
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-09-09 22:18:28 +02:00
2012-09-15 00:00:59 +02:00
describe 'Team events' do
let(:user_project) { stub.as_null_object }
let(:observer) { UsersProjectObserver.instance }
before {
Event.should_receive :create
}
describe "Joined project team" do
it "should create event" do
observer.after_create user_project
end
2012-09-09 22:18:28 +02:00
end
2012-09-15 00:00:59 +02:00
describe "Left project team" do
it "should create event" do
observer.after_destroy user_project
end
2012-09-09 23:27:47 +02:00
end
end
2012-02-28 14:09:23 +01:00
end