Skip to content

Commit fd5b1bf

Browse files
committed
fix linter
1 parent ebcc380 commit fd5b1bf

File tree

1 file changed

+0
-155
lines changed

1 file changed

+0
-155
lines changed

spec/requests/api/v1/plans_controller_spec.rb

Lines changed: 0 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -766,161 +766,6 @@
766766
end
767767
end
768768

769-
context "when editing a fixed charge" do
770-
let(:plan) { create(:plan, organization:, interval: :weekly) }
771-
let(:subscription) { create(:subscription, :active, :anniversary, plan:, started_at:, subscription_at: started_at) }
772-
let(:fixed_charge) { create(:fixed_charge, plan:, add_on:, units: 1) }
773-
let(:started_at) { 3.days.ago }
774-
775-
before { subscription }
776-
777-
context "when apply_units_immediately is true" do
778-
let(:fixed_charges_params) do
779-
[
780-
{
781-
id: fixed_charge.id,
782-
apply_units_immediately: true,
783-
units: 25,
784-
properties: {amount: "10"}
785-
}
786-
]
787-
end
788-
789-
it "updates a fixed charge" do
790-
subject
791-
792-
expect(response).to have_http_status(:success)
793-
expect(json[:plan][:fixed_charges].count).to eq(1)
794-
expect(json[:plan][:fixed_charges].first[:units]).to eq("25.0")
795-
end
796-
797-
it "creates fixed charge events for all active subscriptions with current timestamp" do
798-
expect { subject }.to change(FixedChargeEvent, :count).by(1)
799-
800-
expect(fixed_charge.events.first).to have_attributes(
801-
subscription:,
802-
fixed_charge:,
803-
units: 25,
804-
timestamp: be_within(1.second).of(Time.current)
805-
)
806-
end
807-
end
808-
809-
context "when apply_units_immediately is false" do
810-
let(:fixed_charges_params) do
811-
[
812-
{
813-
id: fixed_charge.id,
814-
apply_units_immediately: false,
815-
units: 25,
816-
properties: {amount: "10"}
817-
}
818-
]
819-
end
820-
821-
it "updates a fixed charge" do
822-
subject
823-
824-
expect(response).to have_http_status(:success)
825-
expect(json[:plan][:fixed_charges].count).to eq(1)
826-
expect(json[:plan][:fixed_charges].first[:units]).to eq("25.0")
827-
end
828-
829-
it "creates fixed charge events for all active subscriptions with next billing period timestamp" do
830-
expect { subject }.to change(FixedChargeEvent, :count).by(1)
831-
832-
expect(fixed_charge.events.first).to have_attributes(
833-
subscription:,
834-
fixed_charge:,
835-
units: 25,
836-
timestamp: be_within(1.second).of((started_at + 1.week).beginning_of_day)
837-
)
838-
end
839-
end
840-
end
841-
842-
context "when adding a fixed charge" do
843-
let(:plan) { create(:plan, organization:, interval: :weekly) }
844-
let(:subscription) { create(:subscription, :active, :calendar, plan:, started_at: started_at) }
845-
let(:started_at) { 3.days.ago }
846-
847-
before { subscription }
848-
849-
context "when apply_units_immediately is true" do
850-
let(:fixed_charges_params) do
851-
[
852-
{
853-
apply_units_immediately: true,
854-
invoice_display_name: "Fixed charge 2",
855-
units: 100,
856-
add_on_id: add_on.id,
857-
charge_model: "standard",
858-
properties: {amount: "10"}
859-
}
860-
]
861-
end
862-
863-
it "adds a fixed charge" do
864-
subject
865-
866-
expect(response).to have_http_status(:success)
867-
expect(json[:plan][:fixed_charges].count).to eq(1)
868-
expect(json[:plan][:fixed_charges].first[:invoice_display_name]).to eq("Fixed charge 2")
869-
expect(json[:plan][:fixed_charges].first[:units]).to eq("100.0")
870-
end
871-
872-
it "creates fixed charge events for all active subscriptions with current timestamp" do
873-
expect { subject }.to change(FixedChargeEvent, :count).by(1)
874-
875-
fixed_charge = FixedCharge.find(json[:plan][:fixed_charges].first[:lago_id])
876-
877-
expect(fixed_charge.events.first).to have_attributes(
878-
subscription:,
879-
fixed_charge:,
880-
units: 100,
881-
timestamp: be_within(5.seconds).of(Time.current)
882-
)
883-
end
884-
end
885-
886-
context "when apply_units_immediately is false" do
887-
let(:fixed_charges_params) do
888-
[
889-
{
890-
apply_units_immediately: false,
891-
invoice_display_name: "Fixed charge 2",
892-
units: 100,
893-
add_on_id: add_on.id,
894-
charge_model: "standard",
895-
properties: {amount: "10"}
896-
}
897-
]
898-
end
899-
900-
it "adds a fixed charge" do
901-
subject
902-
903-
expect(response).to have_http_status(:success)
904-
expect(json[:plan][:fixed_charges].count).to eq(1)
905-
expect(json[:plan][:fixed_charges].first[:invoice_display_name]).to eq("Fixed charge 2")
906-
expect(json[:plan][:fixed_charges].first[:units]).to eq("100.0")
907-
end
908-
909-
it "creates fixed charge events for all active subscriptions with next billing period timestamp" do
910-
expect { subject }.to change(FixedChargeEvent, :count).by(1)
911-
912-
fixed_charge = FixedCharge.find(json[:plan][:fixed_charges].first[:lago_id])
913-
914-
expect(fixed_charge.events.first).to have_attributes(
915-
subscription:,
916-
fixed_charge:,
917-
units: 100,
918-
timestamp: be_within(1.second).of((started_at + 1.week).beginning_of_week)
919-
)
920-
end
921-
end
922-
end
923-
924769
context "when editing a fixed charge" do
925770
let(:plan) { create(:plan, organization:, interval: :weekly) }
926771
let(:subscription) { create(:subscription, :active, :calendar, plan:, started_at: started_at) }

0 commit comments

Comments
 (0)