Skip to content

Commit

Permalink
Readd admin tab to retired documents
Browse files Browse the repository at this point in the history
This was originally removed as you can change document format from this
tab but the tab also houses the delete draft feature which we need.
  • Loading branch information
1pretz1 committed Jul 18, 2023
1 parent 811cfef commit 82fc767
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
3 changes: 1 addition & 2 deletions app/helpers/tabs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ def tabs
def tabs_for(user, resource)
tabs_to_remove = []
tabs_to_remove << "admin" unless user.has_editor_permissions?(resource)
tabs_to_remove << "admin" if resource.retired_format?
tabs_to_remove << "unpublish" unless user.govuk_editor?

tabs.reject { |tab| tabs_to_remove.uniq.include?(tab.name) }
tabs.reject { |tab| tabs_to_remove.include?(tab.name) }
end
end
6 changes: 0 additions & 6 deletions test/unit/tabs_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,5 @@ class TabsHelperTest < ActionView::TestCase
user = FactoryBot.create(:user, :welsh_editor)
assert_equal %w[admin unpublish], (tabs - tabs_for(user, guide)).map(&:name)
end

should "exclude `admin` tab if document retired" do
retired_document = FactoryBot.create(:campaign_edition)
user = FactoryBot.create(:user, :govuk_editor)
assert_equal %w[admin], (tabs - tabs_for(user, retired_document)).map(&:name)
end
end
end

0 comments on commit 82fc767

Please sign in to comment.