Commit a33199f3 authored by Douwe Maan's avatar Douwe Maan Committed by Ruben Davila

Merge branch '21446-service-external-wiki-only-works-when-project-wiki-is-enabled' into 'master'

Fix "Wiki" link not appearing in navigation for projects with external wiki

## Are there points in the code the reviewer needs to double check?

No

## What are the relevant issue numbers?

Closes #21446

## Does this MR meet the acceptance criteria?

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [ ] API support added
- Tests
  - [x] Added for this feature/bug
  - [ ] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [ ] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !6057
parent 99ae4c0d
...@@ -58,6 +58,7 @@ v 8.11.3 (unreleased) ...@@ -58,6 +58,7 @@ v 8.11.3 (unreleased)
- Allow system info page to handle case where info is unavailable - Allow system info page to handle case where info is unavailable
- Label list shows all issues (opened or closed) with that label - Label list shows all issues (opened or closed) with that label
- Don't show resolve conflicts link before MR status is updated - Don't show resolve conflicts link before MR status is updated
- Fix "Wiki" link not appearing in navigation for projects with external wiki
- Fix IE11 fork button bug !598 - Fix IE11 fork button bug !598
- Don't prevent viewing the MR when git refs for conflicts can't be found on disk - Don't prevent viewing the MR when git refs for conflicts can't be found on disk
- Allow system info page to handle case where info is unavailable - Allow system info page to handle case where info is unavailable
......
...@@ -355,7 +355,7 @@ class Ability ...@@ -355,7 +355,7 @@ class Ability
rules += named_abilities('project_snippet') rules += named_abilities('project_snippet')
end end
unless project.wiki_enabled unless project.has_wiki?
rules += named_abilities('wiki') rules += named_abilities('wiki')
end end
......
...@@ -680,6 +680,10 @@ class Project < ActiveRecord::Base ...@@ -680,6 +680,10 @@ class Project < ActiveRecord::Base
update_column(:has_external_issue_tracker, services.external_issue_trackers.any?) update_column(:has_external_issue_tracker, services.external_issue_trackers.any?)
end end
def has_wiki?
wiki_enabled? || has_external_wiki?
end
def external_wiki def external_wiki
if has_external_wiki.nil? if has_external_wiki.nil?
cache_has_external_wiki # Populate cache_has_external_wiki # Populate
......
...@@ -282,4 +282,17 @@ describe Ability, lib: true do ...@@ -282,4 +282,17 @@ describe Ability, lib: true do
end end
end end
end end
describe '.project_disabled_features_rules' do
let(:project) { build(:project) }
subject { described_class.project_disabled_features_rules(project) }
context 'wiki named abilities' do
it 'disables wiki abilities if the project has no wiki' do
expect(project).to receive(:has_wiki?).and_return(false)
expect(subject).to include(:read_wiki, :create_wiki, :update_wiki, :admin_wiki)
end
end
end
end end
...@@ -506,6 +506,18 @@ describe Project, models: true do ...@@ -506,6 +506,18 @@ describe Project, models: true do
end end
end end
describe '#has_wiki?' do
let(:no_wiki_project) { build(:project, wiki_enabled: false, has_external_wiki: false) }
let(:wiki_enabled_project) { build(:project, wiki_enabled: true) }
let(:external_wiki_project) { build(:project, has_external_wiki: true) }
it 'returns true if project is wiki enabled or has external wiki' do
expect(wiki_enabled_project).to have_wiki
expect(external_wiki_project).to have_wiki
expect(no_wiki_project).not_to have_wiki
end
end
describe '#external_wiki' do describe '#external_wiki' do
let(:project) { create(:project) } let(:project) { create(:project) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment