BigW Consortium Gitlab

Commit 4a81867d by 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
...@@ -149,6 +149,12 @@ class WikiPage ...@@ -149,6 +149,12 @@ class WikiPage
end end
# Returns boolean True or False if this instance # 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. # has been fully saved to disk or not.
def persisted? def persisted?
@persisted == true @persisted == true
......
...@@ -4,6 +4,6 @@ ...@@ -4,6 +4,6 @@
New Page New Page
= link_to namespace_project_wiki_history_path(@project.namespace, @project, @page), class: "btn" do = link_to namespace_project_wiki_history_path(@project.namespace, @project, @page), class: "btn" do
Page History 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 = link_to namespace_project_wiki_edit_path(@project.namespace, @project, @page), class: "btn" do
Edit 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