Merge branch '28991-viewing-old-wiki-page-version-edit-button-exists' into 'master'
[#28991] Resolve "Viewing old wiki page version, "Edit" button exists, brings up latest markup" Closes #28991 See merge request !9966
This commit is contained in:
commit
4a81867df1
4 changed files with 55 additions and 1 deletions
|
@ -148,6 +148,12 @@ class WikiPage
|
|||
@page.historical? && versions.first.sha != version.sha
|
||||
end
|
||||
|
||||
# Returns boolean True or False if this instance
|
||||
# is the latest commit version of the page.
|
||||
def latest?
|
||||
!historical?
|
||||
end
|
||||
|
||||
# Returns boolean True or False if this instance
|
||||
# has been fully saved to disk or not.
|
||||
def persisted?
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
New Page
|
||||
= link_to namespace_project_wiki_history_path(@project.namespace, @project, @page), class: "btn" do
|
||||
Page History
|
||||
- if can?(current_user, :create_wiki, @project)
|
||||
- if can?(current_user, :create_wiki, @project) && @page.latest?
|
||||
= link_to namespace_project_wiki_edit_path(@project.namespace, @project, @page), class: "btn" do
|
||||
Edit
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: When viewing old wiki page version, edit button should be disabled
|
||||
merge_request: 9966
|
||||
author: TM Lee
|
|
@ -0,0 +1,44 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'Projects > Wiki > User views the wiki page', feature: true do
|
||||
let(:user) { create(:user) }
|
||||
let(:project) { create(:project, :public) }
|
||||
let(:old_page_version_id) { wiki_page.versions.last.id }
|
||||
let(:wiki_page) do
|
||||
WikiPages::CreateService.new(
|
||||
project,
|
||||
user,
|
||||
title: 'home',
|
||||
content: '[some link](other-page)'
|
||||
).execute
|
||||
end
|
||||
|
||||
background do
|
||||
project.team << [user, :master]
|
||||
login_as(user)
|
||||
WikiPages::UpdateService.new(
|
||||
project,
|
||||
user,
|
||||
message: 'updated home',
|
||||
content: 'updated [some link](other-page)',
|
||||
format: :markdown
|
||||
).execute(wiki_page)
|
||||
end
|
||||
|
||||
scenario 'Visit Wiki Page Current Commit' do
|
||||
visit namespace_project_wiki_path(project.namespace, project, wiki_page)
|
||||
|
||||
expect(page).to have_selector('a.btn', text: 'Edit')
|
||||
end
|
||||
|
||||
scenario 'Visit Wiki Page Historical Commit' do
|
||||
visit namespace_project_wiki_path(
|
||||
project.namespace,
|
||||
project,
|
||||
wiki_page,
|
||||
version_id: old_page_version_id
|
||||
)
|
||||
|
||||
expect(page).not_to have_selector('a.btn', text: 'Edit')
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue