diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-05 15:06:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-05 15:06:20 +0300 |
commit | 791785af5540d18eaa97da24f9ff8638e1960b72 (patch) | |
tree | caeb6f08d9cc10a0052dc6851b46653d94c29022 /spec | |
parent | a92d6b36c2d2892e8c070efb169f0c06815900ee (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/finders/branches_finder_spec.rb | 56 | ||||
-rw-r--r-- | spec/finders/tags_finder_spec.rb | 38 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/ansi2json_spec.rb | 8 | ||||
-rw-r--r-- | spec/services/notification_service_spec.rb | 23 |
4 files changed, 102 insertions, 23 deletions
diff --git a/spec/finders/branches_finder_spec.rb b/spec/finders/branches_finder_spec.rb index 1a33bdf11d7..70b5da0cc3c 100644 --- a/spec/finders/branches_finder_spec.rb +++ b/spec/finders/branches_finder_spec.rb @@ -73,58 +73,76 @@ describe BranchesFinder do expect(result.count).to eq(3) expect(result.map(&:name)).to eq(%w{csv fix lfs}) end - end - context 'filter and sort' do - it 'filters branches by name and sorts by recently_updated' do - params = { sort: 'updated_desc', search: 'feat' } + it 'filters branches by name that begins with' do + params = { search: '^feature_' } branches_finder = described_class.new(repository, params) result = branches_finder.execute expect(result.first.name).to eq('feature_conflict') - expect(result.count).to eq(2) + expect(result.count).to eq(1) end - it 'filters branches by name and sorts by recently_updated, with exact matches first' do - params = { sort: 'updated_desc', search: 'feature' } + it 'filters branches by name that ends with' do + params = { search: 'feature$' } branches_finder = described_class.new(repository, params) result = branches_finder.execute expect(result.first.name).to eq('feature') - expect(result.second.name).to eq('feature_conflict') - expect(result.count).to eq(2) + expect(result.count).to eq(1) end - it 'filters branches by name and sorts by last_updated' do - params = { sort: 'updated_asc', search: 'feature' } + it 'filters branches by nonexistent name that begins with' do + params = { search: '^nope' } branches_finder = described_class.new(repository, params) result = branches_finder.execute - expect(result.first.name).to eq('feature') - expect(result.count).to eq(2) + expect(result.count).to eq(0) end - it 'filters branches by name that begins with' do - params = { search: '^feature_' } + it 'filters branches by nonexistent name that ends with' do + params = { search: 'nope$' } + branches_finder = described_class.new(repository, params) + + result = branches_finder.execute + + expect(result.count).to eq(0) + end + end + + context 'filter and sort' do + it 'filters branches by name and sorts by recently_updated' do + params = { sort: 'updated_desc', search: 'feat' } branches_finder = described_class.new(repository, params) result = branches_finder.execute expect(result.first.name).to eq('feature_conflict') - expect(result.count).to eq(1) + expect(result.count).to eq(2) end - it 'filters branches by name that ends with' do - params = { search: 'feature$' } + it 'filters branches by name and sorts by recently_updated, with exact matches first' do + params = { sort: 'updated_desc', search: 'feature' } branches_finder = described_class.new(repository, params) result = branches_finder.execute expect(result.first.name).to eq('feature') - expect(result.count).to eq(1) + expect(result.second.name).to eq('feature_conflict') + expect(result.count).to eq(2) + end + + it 'filters branches by name and sorts by last_updated' do + params = { sort: 'updated_asc', search: 'feature' } + branches_finder = described_class.new(repository, params) + + result = branches_finder.execute + + expect(result.first.name).to eq('feature') + expect(result.count).to eq(2) end end end diff --git a/spec/finders/tags_finder_spec.rb b/spec/finders/tags_finder_spec.rb index 85f970b71c4..e9f29ab2441 100644 --- a/spec/finders/tags_finder_spec.rb +++ b/spec/finders/tags_finder_spec.rb @@ -54,6 +54,44 @@ describe TagsFinder do expect(result.count).to eq(0) end + + it 'filters tags by name that begins with' do + params = { search: '^v1.0' } + tags_finder = described_class.new(repository, params) + + result = tags_finder.execute + + expect(result.first.name).to eq('v1.0.0') + expect(result.count).to eq(1) + end + + it 'filters tags by name that ends with' do + params = { search: '0.0$' } + tags_finder = described_class.new(repository, params) + + result = tags_finder.execute + + expect(result.first.name).to eq('v1.0.0') + expect(result.count).to eq(1) + end + + it 'filters tags by nonexistent name that begins with' do + params = { search: '^nope' } + tags_finder = described_class.new(repository, params) + + result = tags_finder.execute + + expect(result.count).to eq(0) + end + + it 'filters tags by nonexistent name that ends with' do + params = { search: 'nope$' } + tags_finder = described_class.new(repository, params) + + result = tags_finder.execute + + expect(result.count).to eq(0) + end end context 'filter and sort' do diff --git a/spec/lib/gitlab/ci/ansi2json_spec.rb b/spec/lib/gitlab/ci/ansi2json_spec.rb index 3cd448d1aae..124379fa321 100644 --- a/spec/lib/gitlab/ci/ansi2json_spec.rb +++ b/spec/lib/gitlab/ci/ansi2json_spec.rb @@ -224,17 +224,17 @@ describe Gitlab::Ci::Ansi2json do end end - it 'prevents XSS injection' do - trace = "#{section_start}section_end:1:2<script>alert('XSS Hack!');</script>#{section_end}" + it 'prints HTML tags as is' do + trace = "#{section_start}section_end:1:2<div>hello</div>#{section_end}" expect(convert_json(trace)).to eq([ { offset: 0, - content: [{ text: "section_end:1:2<script>alert('XSS Hack!');</script>" }], + content: [{ text: "section_end:1:2<div>hello</div>" }], section: 'prepare-script', section_header: true }, { - offset: 95, + offset: 75, content: [], section: 'prepare-script', section_duration: '01:03' diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index 2481cd5c006..25900043f11 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -869,6 +869,18 @@ describe NotificationService, :mailer do should_email(user_4) end + it 'adds "subscribed" reason to subscriber emails' do + user_1 = create(:user) + label = create(:label, project: project, issues: [issue]) + issue.reload + label.subscribe(user_1) + + notification.new_issue(issue, @u_disabled) + + email = find_email_for(user_1) + expect(email).to have_header('X-GitLab-NotificationReason', NotificationReason::SUBSCRIBED) + end + it_behaves_like 'project emails are disabled' do let(:notification_target) { issue } let(:notification_trigger) { notification.new_issue(issue, @u_disabled) } @@ -1272,6 +1284,17 @@ describe NotificationService, :mailer do let(:notification_target) { issue } let(:notification_trigger) { notification.close_issue(issue, @u_disabled) } end + + it 'adds "subscribed" reason to subscriber emails' do + user_1 = create(:user) + issue.subscribe(user_1) + issue.reload + + notification.close_issue(issue, @u_disabled) + + email = find_email_for(user_1) + expect(email).to have_header('X-GitLab-NotificationReason', NotificationReason::SUBSCRIBED) + end end describe '#reopen_issue' do |