diff options
author | Valery Sizov <valery@gitlab.com> | 2015-11-05 11:45:58 +0000 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2015-11-05 11:45:58 +0000 |
commit | 4f574388fc8594ec6f6e9d719f524912d17c4059 (patch) | |
tree | 43447b26e57d81765f983ef38e34eb5b3ba10997 /spec | |
parent | 363900a3e7902cbda8f62b55eb2c30881b3dae3f (diff) | |
parent | 6051c28fc03b4d9928ee2f2855f210845f9c0579 (diff) | |
download | gitlab-ce-4f574388fc8594ec6f6e9d719f524912d17c4059.tar.gz |
Merge branch 'public_groups' into 'master'
Allow groups to appear in the search results if the group owner allows it
https://dev.gitlab.org/gitlab/gitlabhq/issues/2565
See merge request !1751
Diffstat (limited to 'spec')
-rw-r--r-- | spec/finders/group_finder_spec.rb | 15 | ||||
-rw-r--r-- | spec/helpers/search_helper_spec.rb | 5 | ||||
-rw-r--r-- | spec/models/group_spec.rb | 19 |
3 files changed, 39 insertions, 0 deletions
diff --git a/spec/finders/group_finder_spec.rb b/spec/finders/group_finder_spec.rb new file mode 100644 index 00000000000..78dc027837c --- /dev/null +++ b/spec/finders/group_finder_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe GroupsFinder do + let(:user) { create :user } + let!(:group) { create :group } + let!(:public_group) { create :group, public: true } + + describe :execute do + it 'finds public group' do + groups = GroupsFinder.new.execute(user) + expect(groups.size).to eq(1) + expect(groups.first).to eq(public_group) + end + end +end diff --git a/spec/helpers/search_helper_spec.rb b/spec/helpers/search_helper_spec.rb index b327f4f911a..ebe9c29d91c 100644 --- a/spec/helpers/search_helper_spec.rb +++ b/spec/helpers/search_helper_spec.rb @@ -42,6 +42,11 @@ describe SearchHelper do expect(search_autocomplete_opts(project.name).size).to eq(1) end + it "includes the public group" do + group = create(:group, public: true) + expect(search_autocomplete_opts(group.name).size).to eq(1) + end + context "with a current project" do before { @project = create(:project) } diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 80638fc8db2..0f23e81ace9 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -84,4 +84,23 @@ describe Group do expect(group.avatar_type).to eq(["only images allowed"]) end end + + describe "public_profile?" do + it "returns true for public group" do + group = create(:group, public: true) + expect(group.public_profile?).to be_truthy + end + + it "returns true for non-public group with public project" do + group = create(:group) + create(:project, :public, group: group) + expect(group.public_profile?).to be_truthy + end + + it "returns false for non-public group with no public projects" do + group = create(:group) + create(:project, group: group) + expect(group.public_profile?).to be_falsy + end + end end |