-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy approvals from previous release
- Loading branch information
gitstart_bot
committed
Dec 6, 2024
1 parent
0bed216
commit 691b23f
Showing
15 changed files
with
404 additions
and
20 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
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 @@ | ||
class Releases::CopyPreviousApprovalsJob < ApplicationJob | ||
queue_as :default | ||
|
||
def perform(release_id) | ||
release = Release.find_by(id: release_id) | ||
unless release | ||
Rails.logger.error("Release with ID #{release_id} not found") | ||
return | ||
end | ||
|
||
release.copy_previous_approvals | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddCopyApprovalsToTrain < ActiveRecord::Migration[7.2] | ||
def change | ||
add_column :trains, :copy_approvals, :boolean, default: false | ||
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
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,44 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Releases::CopyPreviousApprovalsJob do | ||
let(:release) { create(:release) } | ||
let(:release_id) { release.id } | ||
|
||
describe "#perform" do | ||
before do | ||
allow(release).to receive(:copy_previous_approvals).and_wrap_original do |_m, *_args| | ||
create(:approval_item, release: release) | ||
end | ||
|
||
allow(Release).to receive(:find_by).with(id: release_id).and_return(release) | ||
end | ||
|
||
it "adds approval items to the release if none exist" do | ||
expect(release.approval_items).to be_empty | ||
|
||
described_class.perform_now(release_id) | ||
|
||
release.reload | ||
expect(release.approval_items.count).to eq(1) | ||
expect(release.approval_items).to all(be_a(ApprovalItem)) | ||
end | ||
|
||
it "performs the job successfully without errors" do | ||
expect { described_class.perform_now(release_id) }.not_to raise_error | ||
end | ||
|
||
context "when release is not found" do | ||
before do | ||
allow(Release).to receive(:find_by).with(id: release_id).and_return(nil) | ||
end | ||
|
||
it "logs an error if release is not found" do | ||
allow(Rails.logger).to receive(:error) | ||
|
||
described_class.perform_now(release_id) | ||
|
||
expect(Rails.logger).to have_received(:error).with("Release with ID #{release_id} not found") | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.