diff options
author | Clement Ho <ClemMakesApps@gmail.com> | 2018-04-12 13:47:30 -0500 |
---|---|---|
committer | Clement Ho <ClemMakesApps@gmail.com> | 2018-04-12 13:47:30 -0500 |
commit | b8401cd0b201ab9caecb60dcc477637e70da4df9 (patch) | |
tree | e197770a94a39ea4956007503440d13cf0b5434e /spec/support | |
parent | b75f9721df6c7f5231a9d19e38ec8f0395957c0d (diff) | |
parent | 7f01d49b69130343d95d7ec470d69aeb14fb94fe (diff) | |
download | gitlab-ce-b8401cd0b201ab9caecb60dcc477637e70da4df9.tar.gz |
Merge branch 'master' into bootstrap4
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/bare_repo_operations.rb | 10 | ||||
-rw-r--r-- | spec/support/filter_spec_helper.rb | 5 | ||||
-rw-r--r-- | spec/support/helpers/features/branches_helpers.rb | 33 | ||||
-rw-r--r-- | spec/support/matchers/have_emoji.rb | 5 | ||||
-rw-r--r-- | spec/support/reference_parser_helpers.rb | 8 |
5 files changed, 52 insertions, 9 deletions
diff --git a/spec/support/bare_repo_operations.rb b/spec/support/bare_repo_operations.rb index 8eeaa37d3c5..3f4a4243cb6 100644 --- a/spec/support/bare_repo_operations.rb +++ b/spec/support/bare_repo_operations.rb @@ -1,19 +1,15 @@ require 'zlib' class BareRepoOperations - # The ID of empty tree. - # See http://stackoverflow.com/a/40884093/1856239 and https://github.com/git/git/blob/3ad8b5bf26362ac67c9020bf8c30eee54a84f56d/cache.h#L1011-L1012 - EMPTY_TREE_ID = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'.freeze - include Gitlab::Popen def initialize(path_to_repo) @path_to_repo = path_to_repo end - def commit_tree(tree_id, msg, parent: EMPTY_TREE_ID) + def commit_tree(tree_id, msg, parent: Gitlab::Git::EMPTY_TREE_ID) commit_tree_args = ['commit-tree', tree_id, '-m', msg] - commit_tree_args += ['-p', parent] unless parent == EMPTY_TREE_ID + commit_tree_args += ['-p', parent] unless parent == Gitlab::Git::EMPTY_TREE_ID commit_id = execute(commit_tree_args) commit_id[0] @@ -21,7 +17,7 @@ class BareRepoOperations # Based on https://stackoverflow.com/a/25556917/1856239 def commit_file(file, dst_path, branch = 'master') - head_id = execute(['show', '--format=format:%H', '--no-patch', branch], allow_failure: true)[0] || EMPTY_TREE_ID + head_id = execute(['show', '--format=format:%H', '--no-patch', branch], allow_failure: true)[0] || Gitlab::Git::EMPTY_TREE_ID execute(['read-tree', '--empty']) execute(['read-tree', head_id]) diff --git a/spec/support/filter_spec_helper.rb b/spec/support/filter_spec_helper.rb index b871b7ffc90..721d359c2ee 100644 --- a/spec/support/filter_spec_helper.rb +++ b/spec/support/filter_spec_helper.rb @@ -18,6 +18,11 @@ module FilterSpecHelper context.reverse_merge!(project: project) end + render_context = Banzai::RenderContext + .new(context[:project], context[:current_user]) + + context = context.merge(render_context: render_context) + described_class.call(html, context) end diff --git a/spec/support/helpers/features/branches_helpers.rb b/spec/support/helpers/features/branches_helpers.rb new file mode 100644 index 00000000000..3525d9a70a7 --- /dev/null +++ b/spec/support/helpers/features/branches_helpers.rb @@ -0,0 +1,33 @@ +# These helpers allow you to manipulate with sorting features. +# +# Usage: +# describe "..." do +# include Spec::Support::Helpers::Features::BranchesHelpers +# ... +# +# create_branch("feature") +# select_branch("master") +# +module Spec + module Support + module Helpers + module Features + module BranchesHelpers + def create_branch(branch_name, source_branch_name = "master") + fill_in("branch_name", with: branch_name) + select_branch(source_branch_name) + click_button("Create branch") + end + + def select_branch(branch_name) + find(".git-revision-dropdown-toggle").click + + page.within("#new-branch-form .dropdown-menu") do + click_link(branch_name) + end + end + end + end + end + end +end diff --git a/spec/support/matchers/have_emoji.rb b/spec/support/matchers/have_emoji.rb new file mode 100644 index 00000000000..23fb8e9c1c4 --- /dev/null +++ b/spec/support/matchers/have_emoji.rb @@ -0,0 +1,5 @@ +RSpec::Matchers.define :have_emoji do |emoji_name| + match do |actual| + expect(actual).to have_selector("gl-emoji[data-name='#{emoji_name}']") + end +end diff --git a/spec/support/reference_parser_helpers.rb b/spec/support/reference_parser_helpers.rb index 5d5e80851e6..c01897ed1a1 100644 --- a/spec/support/reference_parser_helpers.rb +++ b/spec/support/reference_parser_helpers.rb @@ -5,9 +5,11 @@ module ReferenceParserHelpers shared_examples 'no N+1 queries' do it 'avoids N+1 queries in #nodes_visible_to_user', :request_store do + context = Banzai::RenderContext.new(project, user) + record_queries = lambda do |links| ActiveRecord::QueryRecorder.new do - described_class.new(project, user).nodes_visible_to_user(user, links) + described_class.new(context).nodes_visible_to_user(user, links) end end @@ -19,9 +21,11 @@ module ReferenceParserHelpers end it 'avoids N+1 queries in #records_for_nodes', :request_store do + context = Banzai::RenderContext.new(project, user) + record_queries = lambda do |links| ActiveRecord::QueryRecorder.new do - described_class.new(project, user).records_for_nodes(links) + described_class.new(context).records_for_nodes(links) end end |