-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1762 from tactilenews/1753_add_ability_to_delete_…
…planned_requests [Feature] Add ability to delete planned requests
- Loading branch information
Showing
18 changed files
with
297 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
12 changes: 12 additions & 0 deletions
12
app/components/destroy_planned_request_modal/destroy_planned_request_modal.css
This file contains 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,12 @@ | ||
.DestroyPlannedRequestModal-footer { | ||
display: flex; | ||
margin-top: var(--spacing-unit); | ||
} | ||
|
||
.DestroyPlannedRequestModal-footer .Button:first-child { | ||
margin-right: var(--spacing-unit-xs); | ||
} | ||
|
||
.DestroyPlannedRequestModal-footer .Button:last-child { | ||
margin-left: var(--spacing-unit-xs); | ||
} |
19 changes: 19 additions & 0 deletions
19
app/components/destroy_planned_request_modal/destroy_planned_request_modal.html.erb
This file contains 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,19 @@ | ||
<%= c 'modal', **attrs do %> | ||
<%= c 'heading', tag: :h2 do %> | ||
<%= t('.heading', request_title: planned_request.title) %> | ||
<% end %> | ||
<footer class="DestroyPlannedRequestModal-footer"> | ||
<%= c 'button', | ||
type: 'button', | ||
styles: [:block, :secondary], | ||
data: { action: 'request-form#closeModal' } do %> | ||
<%= t('.cancel') %> | ||
<% end %> | ||
<%= c 'button', | ||
link: request_path(planned_request), | ||
styles: [:block, :destroy], | ||
data: { method: :delete } do %> | ||
<%= t('.confirm') %> | ||
<% end %> | ||
</footer> | ||
<% end %> |
13 changes: 13 additions & 0 deletions
13
app/components/destroy_planned_request_modal/destroy_planned_request_modal.rb
This file contains 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,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module DestroyPlannedRequestModal | ||
class DestroyPlannedRequestModal < ApplicationComponent | ||
def initialize(planned_request:, **) | ||
super | ||
|
||
@planned_request = planned_request | ||
end | ||
|
||
attr_reader :planned_request | ||
end | ||
end |
This file contains 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 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 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 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 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 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 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 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 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 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,58 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe BroadcastRequestJob do | ||
describe '#perform_later(request_id)' do | ||
subject { -> { described_class.new.perform(request.id) } } | ||
|
||
let!(:contributor) { create(:contributor) } | ||
let(:request) { create(:request, broadcasted_at: nil) } | ||
|
||
context 'given the request has been deleted' do | ||
before { request.destroy } | ||
|
||
it 'does not raise an error' do | ||
expect { subject.call }.not_to raise_error | ||
end | ||
|
||
it 'does not create a Message instance' do | ||
expect { subject.call }.not_to change(Message, :count) | ||
end | ||
end | ||
|
||
context 'given a request has been broadcast' do | ||
before { request.update(broadcasted_at: 5.minutes.ago) } | ||
|
||
it 'does not create a Message instance' do | ||
expect { subject.call }.not_to change(Message, :count) | ||
end | ||
|
||
it 'does not update the broadcasted_at attr' do | ||
expect { subject.call }.not_to(change { request.reload.broadcasted_at }) | ||
end | ||
end | ||
|
||
context 'given a request has been rescheduled for the future' do | ||
before { request.update(schedule_send_for: 1.day.from_now) } | ||
let(:expected_params) { { request_id: request.id } } | ||
|
||
it 'enqueues a job to broadcast the request, and broadcast it when called again' do | ||
expect { subject.call }.to change(DelayedJob, :count).from(0).to(1) | ||
expect(Delayed::Job.last.run_at).to be_within(1.second).of(request.schedule_send_for) | ||
|
||
Timecop.travel(1.day.from_now + 2.minutes) | ||
|
||
expect { subject.call }.to change { request.reload.broadcasted_at }.from(nil).to(kind_of(ActiveSupport::TimeWithZone)) | ||
end | ||
|
||
it 'does not create a Message instance' do | ||
expect { subject.call }.not_to change(Message, :count) | ||
end | ||
|
||
it 'does not update the broadcasted_at attr' do | ||
expect { subject.call }.not_to(change { request.reload.broadcasted_at }) | ||
end | ||
end | ||
end | ||
end |
This file contains 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
Oops, something went wrong.