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

D
Dmitriy Zaporozhets 已提交
17 18 19
require 'spec_helper'

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

D
Dmitriy Zaporozhets 已提交
25 26 27 28 29 30 31 32
  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

R
randx 已提交
33 34
  describe "Push event" do
    before do
35
      project = create(:project)
D
Dmitriy Zaporozhets 已提交
36 37
      @user = project.owner

R
randx 已提交
38
      data = {
39 40 41 42 43 44 45 46 47 48 49
        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
D
Dmitriy Zaporozhets 已提交
50 51 52 53
        }
      }

      @event = Event.create(
54
        project: project,
A
Andrew8xx8 已提交
55
        action: Event::PUSHED,
56 57
        data: data,
        author_id: @user.id
D
Dmitriy Zaporozhets 已提交
58 59 60 61
      )
    end

    it { @event.push?.should be_true }
62
    it { @event.proper?.should be_true }
D
Dmitriy Zaporozhets 已提交
63
    it { @event.tag?.should be_false }
D
Dmitriy Zaporozhets 已提交
64 65 66
    it { @event.branch_name.should == "master" }
    it { @event.author.should == @user }
  end
D
Dmitriy Zaporozhets 已提交
67
end