-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementa Job no cadastro de sindico
Co-authored-by: Lucas Lima <[email protected]>
- Loading branch information
1 parent
e95ca4d
commit eb6b980
Showing
23 changed files
with
305 additions
and
203 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
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
class ActiveSuperIntendentJob < ApplicationJob | ||
class ActiveSuperintendentJob < ApplicationJob | ||
queue_as :default | ||
|
||
def perform(superintendent); end | ||
def perform(superintendent) | ||
return unless superintendent.pending? && superintendent.start_date == Date.current | ||
|
||
superintendent.in_action! | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class DesactiveSuperintendentJob < ApplicationJob | ||
queue_as :default | ||
|
||
def perform(superintendent) | ||
return unless superintendent.in_action? && superintendent.end_date == Date.current | ||
|
||
superintendent.closed! | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe ActiveSuperintendentJob, type: :job do | ||
context 'must be activate the superintendent' do | ||
it 'in two days' do | ||
travel_to '2024-07-22'.to_date | ||
superintendent = create :superintendent, :pending, start_date: '2024-07-24'.to_date, | ||
end_date: '2024-08-25'.to_date | ||
|
||
travel_to '2024-07-24'.to_date | ||
ActiveSuperintendentJob.perform_now(superintendent) | ||
expect(superintendent.in_action?).to eq true | ||
end | ||
|
||
it 'does not update if the accused is on another day' do | ||
travel_to '2024-07-22'.to_date | ||
superintendent = create :superintendent, :pending, start_date: '2024-07-24'.to_date, | ||
end_date: '2024-08-25'.to_date | ||
|
||
travel_to '2024-07-23'.to_date | ||
ActiveSuperintendentJob.perform_now(superintendent) | ||
expect(superintendent.in_action?).to eq false | ||
end | ||
|
||
it 'and the status needs to be pending to update' do | ||
travel_to '2024-07-20'.to_date | ||
superintendent_action = create :superintendent, :in_action, start_date: '2024-07-23'.to_date, | ||
end_date: '2024-08-25'.to_date | ||
superintendent_closed = create :superintendent, :closed, start_date: '2024-07-22'.to_date, | ||
end_date: '2024-08-23'.to_date | ||
|
||
travel_to '2024-07-24'.to_date | ||
ActiveSuperintendentJob.perform_now(superintendent_action) | ||
ActiveSuperintendentJob.perform_now(superintendent_closed) | ||
expect(superintendent_action.in_action?).to eq true | ||
expect(superintendent_closed.closed?).to eq true | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe DesactiveSuperintendentJob, type: :job do | ||
context 'must be activate the superintendent' do | ||
it 'in two days' do | ||
travel_to '2024-07-22'.to_date | ||
superintendent = create :superintendent, :in_action, start_date: '2024-07-22'.to_date, | ||
end_date: '2024-07-24'.to_date | ||
|
||
travel_to '2024-07-24'.to_date | ||
DesactiveSuperintendentJob.perform_now(superintendent) | ||
expect(superintendent.closed?).to eq true | ||
end | ||
|
||
it 'does not update if the accused is on another day' do | ||
travel_to '2024-07-22'.to_date | ||
superintendent = create :superintendent, :in_action, start_date: '2024-07-22'.to_date, | ||
end_date: '2024-07-24'.to_date | ||
|
||
travel_to '2024-07-23'.to_date | ||
DesactiveSuperintendentJob.perform_now(superintendent) | ||
expect(superintendent.closed?).to eq false | ||
end | ||
|
||
it 'and the status needs to be in_action to update' do | ||
travel_to '2024-07-20'.to_date | ||
superintendent_action = create :superintendent, :pending, start_date: '2024-07-23'.to_date, | ||
end_date: '2024-07-24'.to_date | ||
superintendent_closed = create :superintendent, :closed, start_date: '2024-07-22'.to_date, | ||
end_date: '2024-07-24'.to_date | ||
|
||
travel_to '2024-07-24'.to_date | ||
DesactiveSuperintendentJob.perform_now(superintendent_action) | ||
DesactiveSuperintendentJob.perform_now(superintendent_closed) | ||
expect(superintendent_action.pending?).to eq true | ||
expect(superintendent_closed.closed?).to eq true | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'rails_helper' | ||
|
||
describe 'Manager closed superintendent' do | ||
context 'delete /condos/:condo_id/superintendents/new' do | ||
it 'must be authenticated to closed an superintendent' do | ||
condo = create :condo | ||
superintendent = create :superintendent | ||
|
||
delete condo_superintendent_path(condo, superintendent) | ||
|
||
expect(response).to redirect_to root_path | ||
expect(Superintendent.last).not_to eq nil | ||
end | ||
|
||
it 'must be authenticated as condo manager to register a superintendent' do | ||
manager = create :manager, is_super: false | ||
condo = create :condo | ||
superintendent = create :superintendent | ||
|
||
login_as manager, scope: :manager | ||
|
||
delete condo_superintendent_path(condo, superintendent) | ||
|
||
expect(response).to redirect_to root_path | ||
expect(Superintendent.last).not_to eq nil | ||
end | ||
|
||
it 'must be authenticated as manager' do | ||
resident = create :resident | ||
condo = create :condo | ||
superintendent = create :superintendent | ||
|
||
login_as resident, scope: :resident | ||
|
||
delete condo_superintendent_path(condo, superintendent) | ||
|
||
expect(response).to redirect_to root_path | ||
expect(Superintendent.last).not_to eq nil | ||
end | ||
end | ||
end |
Oops, something went wrong.