summaryrefslogtreecommitdiff
path: root/spec/models/job_spec.rb
blob: f80519d2640ae4182eb3297151b91424cd1fb7a3 (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
# == Schema Information
#
# Table name: jobs
#
#  id             :integer          not null, primary key
#  project_id     :integer          not null
#  commands       :text
#  active         :boolean          default(TRUE), not null
#  created_at     :datetime
#  updated_at     :datetime
#  name           :string(255)
#  build_branches :boolean          default(TRUE), not null
#  build_tags     :boolean          default(FALSE), not null
#  job_type       :string(255)      default("parallel")
#  refs           :string(255)
#

require 'spec_helper'

describe Job do
  let(:project) { FactoryGirl.create :project }

  it { should belong_to(:project) }
  it { should have_many(:builds) }
  
  describe "run_for_ref?" do
    it "allows run for any ref if refs params is empty" do
      job = FactoryGirl.create :job, project: project
      job.run_for_ref?("anything").should be_true
    end

    it "allows run for any ref in refs params" do
      job = FactoryGirl.create :job, project: project, refs: "master, staging"
      job.run_for_ref?("master").should be_true
      job.run_for_ref?("staging").should be_true
      job.run_for_ref?("anything").should be_false
    end
  end
end