diff options
author | Vinnie Okada <vokada@mrvinn.com> | 2015-04-25 23:01:52 -0600 |
---|---|---|
committer | Vinnie Okada <vokada@mrvinn.com> | 2015-04-26 07:48:19 -0600 |
commit | bd557e4b64a733f4be64b8cf36b8a551d8e8bab7 (patch) | |
tree | bbcfbe5bd73b157755254f9270c0601be4ab74f0 /spec/helpers | |
parent | 439b9f50af3168d33169a4cd25b59e45ea46dc62 (diff) | |
download | gitlab-ce-bd557e4b64a733f4be64b8cf36b8a551d8e8bab7.tar.gz |
Add new admin settings
Add new global application settings for default project and snippet
visibility levels.
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/visibility_level_helper_spec.rb | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/spec/helpers/visibility_level_helper_spec.rb b/spec/helpers/visibility_level_helper_spec.rb new file mode 100644 index 00000000000..3840e64981f --- /dev/null +++ b/spec/helpers/visibility_level_helper_spec.rb @@ -0,0 +1,75 @@ +require 'spec_helper' + +describe VisibilityLevelHelper do + include Haml::Helpers + + before :all do + init_haml_helpers + end + + let(:project) { create(:project) } + + describe 'visibility_level_description' do + shared_examples 'a visibility level description' do + let(:desc) do + visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, + form_model) + end + + let(:expected_class) do + class_name = case form_model.class.name + when 'String' + form_model + else + form_model.class.name + end + + class_name.match(/(project|snippet)$/i)[0] + end + + it 'should refer to the correct class' do + expect(desc).to match(/#{expected_class}/i) + end + end + + context 'form_model argument is a String' do + context 'model object is a personal snippet' do + it_behaves_like 'a visibility level description' do + let(:form_model) { 'PersonalSnippet' } + end + end + + context 'model object is a project snippet' do + it_behaves_like 'a visibility level description' do + let(:form_model) { 'ProjectSnippet' } + end + end + + context 'model object is a project' do + it_behaves_like 'a visibility level description' do + let(:form_model) { 'Project' } + end + end + end + + context 'form_model argument is a model object' do + context 'model object is a personal snippet' do + it_behaves_like 'a visibility level description' do + let(:form_model) { create(:personal_snippet) } + end + end + + context 'model object is a project snippet' do + it_behaves_like 'a visibility level description' do + let(:form_model) { create(:project_snippet, project: project) } + end + end + + context 'model object is a project' do + it_behaves_like 'a visibility level description' do + let(:form_model) { project } + end + end + end + end +end |