-
Notifications
You must be signed in to change notification settings - Fork 42
MMT-2229 Delete published tools #614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
31b1c59
MMT-2229 Adding delete for published tools
william-valencia 22a9fb8
MMT-2229 Updating not current provider modal
ryanmiller-1 db5af95
MMT-2229 Fixing the tool_permissions_spec
william-valencia 47bf0b2
MMT-2229 Removing duplicate test
william-valencia daaa4cf
Fixing spacing for tools_permissions_spec.rb
william-valencia 9eec788
MMT-2229 Modifying delete_tool_spec due to comments and fixing tool_p…
william-valencia e1eedaa
MMT-2229 Removing unneeded delete
william-valencia 55a52ae
MMT-2229 Removing unneeded native_id_3
william-valencia f05fef7
Merge branch 'master' into MMT-2229-Delete-Published-Tools
william-valencia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| describe 'Delete tool', reset_provider: true, js: true do | ||
| before :all do | ||
| @ingested_tool, _concept_response, _native_id_1 = publish_tool_draft | ||
|
|
||
| @ingested_tool_for_delete_messages, _concept_response, @native_id_2 = publish_tool_draft | ||
| end | ||
|
|
||
| # Remove this section after CMR-6332 is resolved | ||
| after :all do | ||
| delete_response = cmr_client.delete_tool('MMT_2', @native_id_2, 'token') | ||
| # First tool should be deleted in the delete test | ||
|
|
||
| raise unless delete_response.success? | ||
| end | ||
|
|
||
| before do | ||
| login | ||
| end | ||
|
|
||
| context 'when viewing a published tool' do | ||
| before do | ||
| visit tool_path(@ingested_tool['concept-id']) | ||
| end | ||
|
|
||
| it 'displays a delete link' do | ||
| expect(page).to have_content('Delete Tool Record') | ||
| end | ||
|
|
||
| context 'when clicking the delete link' do | ||
| before do | ||
| click_on 'Delete Tool Record' | ||
| end | ||
|
|
||
| it 'displays a confirmation modal' do | ||
| expect(page).to have_content('Are you sure you want to delete this tool record?') | ||
| end | ||
|
|
||
| context 'when clicking Yes' do | ||
| before do | ||
| within '#delete-record-modal' do | ||
| click_on 'Yes' | ||
| end | ||
| end | ||
|
|
||
| it 'redirects to the revisions page and displays a confirmation message' do | ||
| expect(page).to have_content('Revision History') | ||
|
|
||
| expect(page).to have_content('Tool Deleted Successfully!') | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
| context 'when deleting the tool will fail' do | ||
| before do | ||
| visit tool_path(@ingested_tool_for_delete_messages['concept-id']) | ||
| end | ||
|
|
||
| context 'when CMR provides a message' do | ||
| before do | ||
| error_body = '{"errors": ["You do not have permission to perform that action."]}' | ||
| error_response = Cmr::Response.new(Faraday::Response.new(status: 401, body: JSON.parse(error_body), response_headers: {})) | ||
| allow_any_instance_of(Cmr::CmrClient).to receive(:delete_tool).and_return(error_response) | ||
|
|
||
| click_on 'Delete Tool Record' | ||
|
|
||
| within '#delete-record-modal' do | ||
| click_on 'Yes' | ||
| end | ||
| end | ||
|
|
||
| it 'displays the CMR error message' do | ||
| expect(page).to have_css('.eui-banner--danger', text: 'You do not have permission to perform that action.') | ||
| end | ||
| end | ||
|
|
||
| context 'when CMR does not provide a message' do | ||
| before do | ||
| error_body = '{"message": "useless message"}' | ||
| error_response = Cmr::Response.new(Faraday::Response.new(status: 401, body: JSON.parse(error_body), response_headers: {})) | ||
| allow_any_instance_of(Cmr::CmrClient).to receive(:delete_tool).and_return(error_response) | ||
|
|
||
| click_on 'Delete Tool Record' | ||
|
|
||
| within '#delete-record-modal' do | ||
| click_on 'Yes' | ||
| end | ||
| end | ||
|
|
||
| it 'displays the CMR error message' do | ||
| expect(page).to have_css('.eui-banner--danger', text: 'Tool was not deleted successfully') | ||
| end | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,12 +9,10 @@ | |
| context "when the tool's provider is in the users available providers" do | ||
| before :all do | ||
| @ingested_tool, _concept_response, @native_id_1 = publish_tool_draft | ||
| # @ingested_tool_for_delete_modal, _concept_response, _native_id_2 = publish_tool_draft | ||
| end | ||
|
|
||
| after :all do | ||
| delete_response = cmr_client.delete_tool('MMT_2', @native_id_1, 'token') | ||
| # Second tool should be deleted in the delete test | ||
|
|
||
| raise unless delete_response.success? | ||
| end | ||
|
|
@@ -84,46 +82,38 @@ | |
| end | ||
| end | ||
|
|
||
| # TODO: Uncomment in MMT-2229 | ||
| # context 'when clicking the delete link' do | ||
| # context 'when the tool has no associated collections' do | ||
| # before do | ||
| # visit tool_path(@ingested_tool_for_delete_modal['concept-id']) | ||
| # | ||
| # click_on 'Delete Tool Record' | ||
| # end | ||
| # | ||
| # it 'displays a modal informing the user they need to switch providers' do | ||
| # expect(page).to have_content("Deleting this tool #{modal_text}") | ||
| # end | ||
| # | ||
| # it 'does not display a message about collection associations that will also be deleted' do | ||
| # expect(page).to have_no_content('This tool is associated with') | ||
| # expect(page).to have_no_content('collections. Deleting this tool will also delete the collection associations') | ||
| # end | ||
| # end | ||
| # | ||
| # context 'when deleting the tool' do | ||
| # before do | ||
| # ingested_tool_to_delete, _concept_response = publish_tool_draft | ||
| # | ||
| # visit tool_path(ingested_tool_to_delete['concept-id']) | ||
| # | ||
| # click_on 'Delete Tool Record' | ||
| # | ||
| # find('.not-current-provider-link').click | ||
| # wait_for_jQuery | ||
| # end | ||
| # | ||
| # it 'switches the provider context' do | ||
| # expect(User.first.provider_id).to eq('MMT_2') | ||
| # end | ||
| # | ||
| # it 'deletes the record' do | ||
| # expect(page).to have_content('Tool Deleted Successfully!') | ||
| # end | ||
| # end | ||
| # end | ||
| context 'when clicking the delete link' do | ||
| before do | ||
| @ingested_tool_for_delete_modal, _concept_response, @native_id_2 = publish_tool_draft | ||
| login(provider: 'MMT_1', providers: %w(MMT_1 MMT_2)) | ||
| visit tool_path(@ingested_tool_for_delete_modal['concept-id']) | ||
|
|
||
| click_on 'Delete Tool Record' | ||
| end | ||
|
|
||
| it 'displays a modal informing the user they need to switch providers' do | ||
| expect(page).to have_content("Deleting this tool #{modal_text}") | ||
|
|
||
| # Remove this section after CMR-6332 is resolved | ||
| delete_response = cmr_client.delete_tool('MMT_2', @native_id_2, 'token') | ||
| raise unless delete_response.success? | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noticed that this test was still making searching tools have the error from CMR-6332. Should be able to remove this part after CMR-6332 is resolved. |
||
| end | ||
|
|
||
| context 'when clicking Yes' do | ||
| before do | ||
| find('.not-current-provider-link').click | ||
| wait_for_jQuery | ||
| end | ||
|
|
||
| it 'switches the provider context' do | ||
| expect(User.first.provider_id).to eq('MMT_2') | ||
| end | ||
|
|
||
| it 'deletes the record' do | ||
| expect(page).to have_content('Tool Deleted Successfully!') | ||
| end | ||
| end | ||
| end | ||
|
|
||
| context 'when trying to visit the action paths directly' do | ||
| context 'when visiting the edit path directly' do | ||
|
|
@@ -194,8 +184,7 @@ | |
| it 'does not display the action links' do | ||
| expect(page).to have_no_link('Edit Tool Record') | ||
| expect(page).to have_no_link('Clone Tool Record') | ||
| # TODO: Uncomment in MMT-2229 | ||
| # expect(page).to have_no_link('Delete Tool Record') | ||
| expect(page).to have_no_link('Delete Tool Record') | ||
| end | ||
|
|
||
| context 'when trying to visit the action paths directly' do | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add a comment to remove this after the reset_provider ticket is resolved (can't recall the ticket number right now)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CMR-6332
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment added