-
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.
Merge pull request #149 from TreinaDev/job-cadastro-sindico
Incrementa o active Job no cadastro de sindico
- Loading branch information
Showing
23 changed files
with
349 additions
and
188 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class ActiveSuperintendentJob < ApplicationJob | ||
queue_as :default | ||
|
||
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 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,5 @@ | ||
class AddStatusToSuperintendent < ActiveRecord::Migration[7.1] | ||
def change | ||
add_column :superintendents, :status, :integer | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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' | ||
superintendent = create :superintendent, :pending, start_date: '2024-07-24'.to_date, | ||
end_date: '2024-08-25'.to_date | ||
|
||
travel_to '2024-07-24' | ||
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' | ||
superintendent = create :superintendent, :pending, start_date: '2024-07-24'.to_date, | ||
end_date: '2024-08-25'.to_date | ||
|
||
travel_to '2024-07-23' | ||
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' | ||
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' | ||
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 desactivate the superintendent' do | ||
it 'in two days' do | ||
travel_to '2024-07-22' | ||
superintendent = create :superintendent, :in_action, start_date: '2024-07-22'.to_date, | ||
end_date: '2024-07-24'.to_date | ||
|
||
travel_to '2024-07-24' | ||
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' | ||
superintendent = create :superintendent, :in_action, start_date: '2024-07-22'.to_date, | ||
end_date: '2024-07-24'.to_date | ||
|
||
travel_to '2024-07-23' | ||
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' | ||
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' | ||
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 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/:id' 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.