BigW Consortium Gitlab

event_spec.rb 1.66 KB
Newer Older
Dmitriy Zaporozhets committed
1 2 3 4
# == Schema Information
#
# Table name: events
#
5
#  id          :integer          not null, primary key
Dmitriy Zaporozhets committed
6 7 8 9 10
#  target_type :string(255)
#  target_id   :integer
#  title       :string(255)
#  data        :text
#  project_id  :integer
Dmitriy Zaporozhets committed
11 12
#  created_at  :datetime
#  updated_at  :datetime
Dmitriy Zaporozhets committed
13 14 15 16
#  action      :integer
#  author_id   :integer
#

17 18 19
require 'spec_helper'

describe Event do
20
  describe "Associations" do
21 22
    it { is_expected.to belong_to(:project) }
    it { is_expected.to belong_to(:target) }
23 24
  end

25
  describe "Respond to" do
26 27 28 29 30
    it { is_expected.to respond_to(:author_name) }
    it { is_expected.to respond_to(:author_email) }
    it { is_expected.to respond_to(:issue_title) }
    it { is_expected.to respond_to(:merge_request_title) }
    it { is_expected.to respond_to(:commits) }
31 32
  end

randx committed
33 34
  describe "Push event" do
    before do
35
      project = create(:project)
36 37
      @user = project.owner

randx committed
38
      data = {
39
        before: Gitlab::Git::BLANK_SHA,
40 41 42 43 44 45 46 47 48 49
        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
50 51 52 53
        }
      }

      @event = Event.create(
54
        project: project,
55
        action: Event::PUSHED,
56 57
        data: data,
        author_id: @user.id
58 59 60
      )
    end

61 62 63 64 65
    it { expect(@event.push?).to be_truthy }
    it { expect(@event.proper?).to be_truthy }
    it { expect(@event.tag?).to be_falsey }
    it { expect(@event.branch_name).to eq("master") }
    it { expect(@event.author).to eq(@user) }
66
  end
67
end