Welcome to mirror list, hosted at ThFree Co, Russian Federation.

protected_branch_spec.rb « models « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c6b09f358fb2743fea331137257bc8c73a3c777f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require 'spec_helper'

describe ProtectedBranch do
  describe 'Associations' do
    it { should belong_to(:project) }
  end

  describe "Mass assignment" do
    it { should_not allow_mass_assignment_of(:project_id) }
  end

  describe 'Validation' do
    it { should validate_presence_of(:project) }
    it { should validate_presence_of(:name) }
  end

  describe 'Callbacks' do
    let(:branch) { build(:protected_branch) }

    it 'call update_repository after save' do
      branch.should_receive(:update_repository)
      branch.save
    end

    it 'call update_repository after destroy' do
      branch.save
      branch.should_receive(:update_repository)
      branch.destroy
    end
  end

  describe '#commit' do
    let(:branch) { create(:protected_branch) }

    it 'commits itself to its project' do
      branch.project.should_receive(:commit).with(branch.name)
      branch.commit
    end
  end
end