Skip to content

Commit

Permalink
Removing Edit button from show of approved work
Browse files Browse the repository at this point in the history
Only curators and super admins should have edit capabilites on approved works.
There is a pending test, becuase there is a bug on the edit screen for approved works (#505).
  • Loading branch information
carolyncole committed Oct 17, 2022
1 parent 65dac17 commit 1c386fd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/views/works/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
</style>

<div>
<%= link_to("Edit", edit_work_path(@work, wizard: @work.draft? ? true : nil), class: "btn btn-primary") %>
<% if @work.draft? || @work.awaiting_approval? || current_user.has_role?(:collection_admin, @work.collection) %>
<%= link_to("Edit", edit_work_path(@work, wizard: @work.draft? ? true : nil), class: "btn btn-primary") %>
<% end %>
<% if @work.awaiting_approval? && current_user.has_role?(:collection_admin, @work.collection) %>
<%= button_to("Approve Dataset", approve_work_path(@work), class: "btn btn-secondary", method: :post) %>
<% elsif @work.approved? %>
Expand Down
29 changes: 28 additions & 1 deletion spec/system/view_data_in_s3_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
work.pre_curation_uploads.attach(file)
work.save
work.reload
work.state = "accepted"
work.state = "awaiting_approval"
work.save

visit work_path(work)
Expand All @@ -59,5 +59,32 @@
expect(page).to have_content ActiveStorage::Filename.new(file1.filename).to_s
expect(page).to have_content ActiveStorage::Filename.new(file2.filename).to_s
end

context "when item is approved" do
let(:work) { FactoryBot.create(:approved_work) }
it "shows data from S3" do
stub_s3(data: s3_data)
visit work_path(work)
expect(page).to have_content file1.filename
expect(page).to have_content file2.filename

expect(page).not_to have_button("Edit")
end

context "when user is a curator" do
let(:user) { FactoryBot.create(:research_data_moderator) }
pending "shows data from S3" do
stub_s3(data: s3_data)
visit work_path(work)
expect(page).to have_content file1.filename
expect(page).to have_content file2.filename

click_on "Edit"
expect(page).to have_content file1.filename
expect(page).to have_content file2.filename

end
end
end
end
end

0 comments on commit 1c386fd

Please sign in to comment.