Commit 4a81867d authored by Rémy Coutable's avatar Rémy Coutable

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
parents abb5f765 333e39d4
......@@ -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
---
title: When viewing old wiki page version, edit button should be disabled
merge_request: 9966
author: TM Lee
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
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