-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathcommit_test.rb
53 lines (44 loc) · 1.6 KB
/
commit_test.rb
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
require 'test_helper'
class CommitTest < ActiveSupport::TestCase
test '.merge_or_skip_ci? for merge commits' do
assert_equal true, Commit.merge_or_skip_ci?(CommitReviewer::MERGE_COMMIT_MESSAGE)
assert_equal false, Commit.merge_or_skip_ci?('haha')
end
test '.merge_or_skip_ci? for ci skip commits' do
assert_equal true, Commit.merge_or_skip_ci?(CommitReviewer::CI_SKIP_COMMIT_MESSAGE)
assert_equal true, Commit.merge_or_skip_ci?(CommitReviewer::SKIP_CI_COMMIT_MESSAGE)
assert_equal true, Commit.merge_or_skip_ci?(CommitReviewer::SKIP_CI_COMMIT_MESSAGE.upcase)
assert_equal true, Commit.merge_or_skip_ci?(CommitReviewer::SKIP_CI_COMMIT_MESSAGE.upcase)
end
test '.valid_author?' do
assert_equal true, Commit.valid_author?('Alan')
CommitReviewer::INVALID_AUTHORS.each do |author_name|
assert_equal false, Commit.valid_author?(author_name)
end
end
test '#version' do
commit = create(:commit, sha1: '1234567')
assert_includes commit.version, '12345'
end
test 'validates valid URL' do
valid_url = [
'https://github.com/ruby-bench/ruby-bench-web/blob/master/app/models/commit.rb',
'http://github.com/ruby-bench/ruby-bench-web/blob/master/app/models/commit.rb'
]
valid_url.each do |url|
commit = build(:commit, url: url)
assert commit.valid?
end
end
test 'validates invalid URL' do
invalid_url = [
'httpgithub.com/ruby-bench/ruby-bench-web/',
'INVLAID URL',
'ftp://github.com'
]
invalid_url.each do |url|
commit = build(:commit, url: url)
assert commit.invalid?
end
end
end