summaryrefslogtreecommitdiff
blob: 8d3948c9f80eee959a0468a3ed1c8b8b05f2588a (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
require 'test_helper'

class GlsaTest < ActiveSupport::TestCase
  fixtures :glsas, :users
  
  test "uniqueness" do
    glsa = Glsa.new(:glsa_id => glsas(:glsa_one).glsa_id)
    
    assert !glsa.save
    assert glsa.invalid?(:glsa_id)
  end
  
  test "successful creation" do
    glsa = Glsa.new(:glsa_id => "GLSA-2004-99")
    
    glsa.submitter = users(:test_user)
    glsa.requester = users(:test_user)
    glsa.bugreadymaker = users(:test_user)
    
    assert glsa.save
  end
  
  test "new request" do
    glsa = Glsa.new_request(
      "Some title", 
      "236060, 260006",
      "some comment", 
      "public", 
      false,
      users(:test_user)
    )
    
    assert_equal(glsa.last_revision.title, "Some title")
    assert_equal(glsa.last_revision.bugs.map{|bug| bug.bug_id}.sort, [236060, 260006])
    assert_equal(glsa.comments.first.text, "some comment")
    assert !glsa.restricted
  end
  
  test "adding bulk references" do
    glsa = glsas(:glsa_two)

    glsa.add_references([
      {:title => "REF1", :url => "http://ref1/"},
      {:title => "REF2", :url => "http://ref2/"}
    ])
    
    assert glsa.valid?
    
    rev = glsa.last_revision
    assert rev.valid?
    assert_equal 'REF1', rev.references[0].title
    assert_equal 'http://ref1/', rev.references[0].url
    assert_equal 'REF2', rev.references[1].title
    assert_equal 'http://ref2/', rev.references[1].url
  end
end