Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-16 12:08:27 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-16 12:08:27 +0300
commit6cf1f4c521a621fa2b4dc1735bf5a8c2846f7e6a (patch)
tree38552a384dea3be946ed69cb395b52cdde52f85d /spec/models
parent36c3f8296f0309642d3b41b7d0e0333e50ac75a6 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/snippet_input_action_collection_spec.rb8
-rw-r--r--spec/models/snippet_input_action_spec.rb58
2 files changed, 41 insertions, 25 deletions
diff --git a/spec/models/snippet_input_action_collection_spec.rb b/spec/models/snippet_input_action_collection_spec.rb
index 0cafd41eb6e..ef18ab5a810 100644
--- a/spec/models/snippet_input_action_collection_spec.rb
+++ b/spec/models/snippet_input_action_collection_spec.rb
@@ -36,4 +36,12 @@ describe SnippetInputActionCollection do
end
end
end
+
+ context 'when allowed_actions param is passed' do
+ it 'builds SnippetInputAction with that param' do
+ expect(SnippetInputAction).to receive(:new).with(hash_including(allowed_actions: :create))
+
+ described_class.new([action], allowed_actions: :create)
+ end
+ end
end
diff --git a/spec/models/snippet_input_action_spec.rb b/spec/models/snippet_input_action_spec.rb
index d1c66216cea..5e379a48171 100644
--- a/spec/models/snippet_input_action_spec.rb
+++ b/spec/models/snippet_input_action_spec.rb
@@ -6,34 +6,42 @@ describe SnippetInputAction do
describe 'validations' do
using RSpec::Parameterized::TableSyntax
- where(:action, :file_path, :content, :previous_path, :is_valid, :invalid_field) do
- :create | 'foobar' | 'foobar' | 'foobar' | true | nil
- :move | 'foobar' | 'foobar' | 'foobar' | true | nil
- :delete | 'foobar' | 'foobar' | 'foobar' | true | nil
- :update | 'foobar' | 'foobar' | 'foobar' | true | nil
- :foo | 'foobar' | 'foobar' | 'foobar' | false | :action
- 'create' | 'foobar' | 'foobar' | 'foobar' | true | nil
- 'move' | 'foobar' | 'foobar' | 'foobar' | true | nil
- 'delete' | 'foobar' | 'foobar' | 'foobar' | true | nil
- 'update' | 'foobar' | 'foobar' | 'foobar' | true | nil
- 'foo' | 'foobar' | 'foobar' | 'foobar' | false | :action
- nil | 'foobar' | 'foobar' | 'foobar' | false | :action
- '' | 'foobar' | 'foobar' | 'foobar' | false | :action
- :move | 'foobar' | 'foobar' | nil | false | :previous_path
- :move | 'foobar' | 'foobar' | '' | false | :previous_path
- :create | 'foobar' | nil | 'foobar' | false | :content
- :create | 'foobar' | '' | 'foobar' | false | :content
- :create | nil | 'foobar' | 'foobar' | false | :file_path
- :create | '' | 'foobar' | 'foobar' | false | :file_path
- :update | 'foobar' | nil | 'foobar' | false | :content
- :update | 'foobar' | '' | 'foobar' | false | :content
- :update | 'other' | 'foobar' | 'foobar' | false | :file_path
- :update | 'foobar' | 'foobar' | nil | true | nil
- :update | 'foobar' | 'foobar' | '' | true | nil
+ where(:action, :file_path, :content, :previous_path, :allowed_actions, :is_valid, :invalid_field) do
+ :create | 'foobar' | 'foobar' | 'foobar' | nil | true | nil
+ :move | 'foobar' | 'foobar' | 'foobar' | nil | true | nil
+ :delete | 'foobar' | 'foobar' | 'foobar' | nil | true | nil
+ :update | 'foobar' | 'foobar' | 'foobar' | nil | true | nil
+ :foo | 'foobar' | 'foobar' | 'foobar' | nil | false | :action
+ 'create' | 'foobar' | 'foobar' | 'foobar' | nil | true | nil
+ 'move' | 'foobar' | 'foobar' | 'foobar' | nil | true | nil
+ 'delete' | 'foobar' | 'foobar' | 'foobar' | nil | true | nil
+ 'update' | 'foobar' | 'foobar' | 'foobar' | nil | true | nil
+ 'foo' | 'foobar' | 'foobar' | 'foobar' | nil | false | :action
+ nil | 'foobar' | 'foobar' | 'foobar' | nil | false | :action
+ '' | 'foobar' | 'foobar' | 'foobar' | nil | false | :action
+ :move | 'foobar' | 'foobar' | nil | nil | false | :previous_path
+ :move | 'foobar' | 'foobar' | '' | nil | false | :previous_path
+ :create | 'foobar' | nil | 'foobar' | nil | false | :content
+ :create | 'foobar' | '' | 'foobar' | nil | false | :content
+ :create | nil | 'foobar' | 'foobar' | nil | false | :file_path
+ :create | '' | 'foobar' | 'foobar' | nil | false | :file_path
+ :update | 'foobar' | nil | 'foobar' | nil | false | :content
+ :update | 'foobar' | '' | 'foobar' | nil | false | :content
+ :update | 'other' | 'foobar' | 'foobar' | nil | false | :file_path
+ :update | 'foobar' | 'foobar' | nil | nil | true | nil
+ :update | 'foobar' | 'foobar' | '' | nil | true | nil
+ :update | 'foobar' | 'foobar' | '' | :update | true | nil
+ :update | 'foobar' | 'foobar' | '' | 'update' | true | nil
+ :update | 'foobar' | 'foobar' | '' | [:update] | true | nil
+ :update | 'foobar' | 'foobar' | '' | [:update, :create] | true | nil
+ :update | 'foobar' | 'foobar' | '' | :create | false | :action
+ :update | 'foobar' | 'foobar' | '' | 'create' | false | :action
+ :update | 'foobar' | 'foobar' | '' | [:create] | false | :action
+ :foo | 'foobar' | 'foobar' | '' | :foo | false | :action
end
with_them do
- subject { described_class.new(action: action, file_path: file_path, content: content, previous_path: previous_path) }
+ subject { described_class.new(action: action, file_path: file_path, content: content, previous_path: previous_path, allowed_actions: allowed_actions) }
specify do
expect(subject.valid?).to be is_valid