event_spec.rb 1.29 KB
Newer Older
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
1 2 3
require 'spec_helper'

describe Event do
4 5 6 7
  describe "Associations" do
    it { should belong_to(:project) }
  end

8 9 10 11 12 13 14 15 16 17 18 19 20 21
  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

  describe "Push event" do 
    before do 
      project = Factory :project
      @user = project.owner

      data = { 
22 23 24 25 26 27 28 29 30 31 32
        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
33 34 35 36
        }
      }

      @event = Event.create(
37 38 39 40
        project: project,
        action: Event::Pushed,
        data: data,
        author_id: @user.id
41 42 43 44 45 46
      )
    end

    it { @event.push?.should be_true }
    it { @event.allowed?.should be_true }
    it { @event.new_branch?.should be_true }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
47
    it { @event.tag?.should be_false }
48 49 50
    it { @event.branch_name.should == "master" }
    it { @event.author.should == @user }
  end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
51
end