Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(2965) Clean up leftovers from "ISPF in stealth mode" feature flag #2264

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/models/activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,6 @@ class Activity < ApplicationRecord
where(programme_status: ["completed", "stopped", "cancelled"])
}

scope :not_ispf, -> { where.not(source_fund_code: Fund.by_short_name("ISPF")) }

def self.new_child(parent_activity:, partner_organisation:, is_oda: nil, &block)
attributes = ActivityDefaults.new(
parent_activity: parent_activity,
Expand Down
4 changes: 0 additions & 4 deletions app/models/fund.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ def all
valid_codes.map { |code| new(code) }
end

def not_ispf
(valid_codes - [4]).map { |code| new(code) }
end

def codelist
Codelist.new(type: "fund_types", source: "beis")
end
Expand Down
2 changes: 0 additions & 2 deletions app/models/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ class Report < ApplicationRecord
where(fund_id: activity.associated_fund.id, organisation_id: activity.organisation_id, is_oda: activity.is_oda)
end

scope :not_ispf, -> { where.not(fund_id: Activity.by_roda_identifier("ISPF").id) }

def self.editable_for_activity(activity)
editable.for_activity(activity).first
end
Expand Down
13 changes: 0 additions & 13 deletions spec/models/fund_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,6 @@
end
end

describe ".not_ispf" do
it "returns a Fund for every entry in the 'fund_types' codelist except for ISPF" do
codelist = Codelist.new(type: "fund_types", source: "beis")

funds = described_class.not_ispf
expect(funds.size).to eq(codelist.list.size - 1)

non_ispf_ids = [1, 2, 3]
ids = funds.map(&:id)
expect(ids).to eq(non_ispf_ids)
end
end

describe "#gcrf?" do
let(:fund) { described_class.new(id) }
subject { fund.gcrf? }
Expand Down
124 changes: 42 additions & 82 deletions spec/views/exports/organisations/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,106 +22,66 @@
context "when the current user is a BEIS user" do
let(:user) { build(:beis_user) }

context "and the feature flag hiding ISPF is not enabled" do
before do
assign(:funds, Fund.all)
before do
assign(:funds, Fund.all)

render
end

it "shows the link to download all actuals" do
expect(rendered).to have_export_row(report: "All actuals", path: actuals_exports_organisation_path(organisation, format: "csv"))
end

it "shows the links to download the XML" do
expect(rendered).to have_export_row(report: "XML Download 1", path: "http://example.com/1")
expect(rendered).to have_export_row(report: "XML Download 2", path: "http://example.com/2")
end

it "shows the links to download the external income" do
expect(rendered).to have_export_row(report: "Newton Fund external income", path: external_income_exports_organisation_path(organisation, fund_id: 1, format: "csv"))
expect(rendered).to have_export_row(report: "Global Challenges Research Fund external income", path: external_income_exports_organisation_path(organisation, fund_id: 2, format: "csv"))
expect(rendered).to have_export_row(report: "Other ODA external income", path: external_income_exports_organisation_path(organisation, fund_id: 3, format: "csv"))
expect(rendered).to have_export_row(report: "International Science Partnerships Fund external income", path: external_income_exports_organisation_path(organisation, fund_id: 4, format: "csv"))
end

it "shows the links to download the spending breakdown" do
expect(rendered).to have_export_row(report: "Newton Fund spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 1, format: "csv"))
expect(rendered).to have_export_row(report: "Global Challenges Research Fund spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 2, format: "csv"))
expect(rendered).to have_export_row(report: "Other ODA spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 3, format: "csv"))
expect(rendered).to have_export_row(report: "International Science Partnerships Fund spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 4, format: "csv"))
end
render
end

context "and the feature flag hiding ISPF is enabled" do
before do
assign(:funds, Fund.not_ispf)
it "shows the link to download all actuals" do
expect(rendered).to have_export_row(report: "All actuals", path: actuals_exports_organisation_path(organisation, format: "csv"))
end

render
end
it "shows the links to download the XML" do
expect(rendered).to have_export_row(report: "XML Download 1", path: "http://example.com/1")
expect(rendered).to have_export_row(report: "XML Download 2", path: "http://example.com/2")
end

it "does not show the link to download the ISPF external income" do
expect(rendered).to have_export_row(report: "Newton Fund external income", path: external_income_exports_organisation_path(organisation, fund_id: 1, format: "csv"))
expect(rendered).to_not have_export_row(report: "International Science Partnerships Fund external income", path: external_income_exports_organisation_path(organisation, fund_id: 4, format: "csv"))
end
it "shows the links to download the external income" do
expect(rendered).to have_export_row(report: "Newton Fund external income", path: external_income_exports_organisation_path(organisation, fund_id: 1, format: "csv"))
expect(rendered).to have_export_row(report: "Global Challenges Research Fund external income", path: external_income_exports_organisation_path(organisation, fund_id: 2, format: "csv"))
expect(rendered).to have_export_row(report: "Other ODA external income", path: external_income_exports_organisation_path(organisation, fund_id: 3, format: "csv"))
expect(rendered).to have_export_row(report: "International Science Partnerships Fund external income", path: external_income_exports_organisation_path(organisation, fund_id: 4, format: "csv"))
end

it "does not show the link to download the ISPF spending breakdown" do
expect(rendered).to have_export_row(report: "Newton Fund spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 1, format: "csv"))
expect(rendered).to_not have_export_row(report: "International Science Partnerships Fund spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 4, format: "csv"))
end
it "shows the links to download the spending breakdown" do
expect(rendered).to have_export_row(report: "Newton Fund spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 1, format: "csv"))
expect(rendered).to have_export_row(report: "Global Challenges Research Fund spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 2, format: "csv"))
expect(rendered).to have_export_row(report: "Other ODA spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 3, format: "csv"))
expect(rendered).to have_export_row(report: "International Science Partnerships Fund spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 4, format: "csv"))
end
end

context "when the current user is a partner organisation user" do
let(:user) { build(:partner_organisation_user, organisation: organisation) }

context "and the feature flag hiding ISPF is not enabled" do
before do
assign(:funds, Fund.all)
before do
assign(:funds, Fund.all)

render
end

it "does not show the link to download all actuals" do
expect(rendered).to_not have_export_row(report: "All actuals", path: actuals_exports_organisation_path(organisation, format: "csv"))
end

it "does not show the links to download the XML" do
expect(rendered).to_not have_export_row(report: "XML Download 1", path: "http://example.com/1")
expect(rendered).to_not have_export_row(report: "XML Download 2", path: "http://example.com/2")
end

it "shows the links to download the external income" do
expect(rendered).to have_export_row(report: "Newton Fund external income", path: external_income_exports_organisation_path(organisation, fund_id: 1, format: "csv"))
expect(rendered).to have_export_row(report: "Global Challenges Research Fund external income", path: external_income_exports_organisation_path(organisation, fund_id: 2, format: "csv"))
expect(rendered).to have_export_row(report: "Other ODA external income", path: external_income_exports_organisation_path(organisation, fund_id: 3, format: "csv"))
expect(rendered).to have_export_row(report: "International Science Partnerships Fund external income", path: external_income_exports_organisation_path(organisation, fund_id: 4, format: "csv"))
end

it "shows the links to download the spending breakdown" do
expect(rendered).to have_export_row(report: "Newton Fund spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 1, format: "csv"))
expect(rendered).to have_export_row(report: "Global Challenges Research Fund spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 2, format: "csv"))
expect(rendered).to have_export_row(report: "Other ODA spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 3, format: "csv"))
expect(rendered).to have_export_row(report: "International Science Partnerships Fund spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 4, format: "csv"))
end
render
end

context "and the feature flag hiding ISPF is enabled" do
before do
assign(:funds, Fund.not_ispf)
it "does not show the link to download all actuals" do
expect(rendered).to_not have_export_row(report: "All actuals", path: actuals_exports_organisation_path(organisation, format: "csv"))
end

render
end
it "does not show the links to download the XML" do
expect(rendered).to_not have_export_row(report: "XML Download 1", path: "http://example.com/1")
expect(rendered).to_not have_export_row(report: "XML Download 2", path: "http://example.com/2")
end

it "does not show the link to download the ISPF external income" do
expect(rendered).to have_export_row(report: "Newton Fund external income", path: external_income_exports_organisation_path(organisation, fund_id: 1, format: "csv"))
expect(rendered).to_not have_export_row(report: "International Science Partnerships Fund external income", path: external_income_exports_organisation_path(organisation, fund_id: 4, format: "csv"))
end
it "shows the links to download the external income" do
expect(rendered).to have_export_row(report: "Newton Fund external income", path: external_income_exports_organisation_path(organisation, fund_id: 1, format: "csv"))
expect(rendered).to have_export_row(report: "Global Challenges Research Fund external income", path: external_income_exports_organisation_path(organisation, fund_id: 2, format: "csv"))
expect(rendered).to have_export_row(report: "Other ODA external income", path: external_income_exports_organisation_path(organisation, fund_id: 3, format: "csv"))
expect(rendered).to have_export_row(report: "International Science Partnerships Fund external income", path: external_income_exports_organisation_path(organisation, fund_id: 4, format: "csv"))
end

it "does not show the link to download the ISPF spending breakdown" do
expect(rendered).to have_export_row(report: "Newton Fund spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 1, format: "csv"))
expect(rendered).to_not have_export_row(report: "International Science Partnerships Fund spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 4, format: "csv"))
end
it "shows the links to download the spending breakdown" do
expect(rendered).to have_export_row(report: "Newton Fund spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 1, format: "csv"))
expect(rendered).to have_export_row(report: "Global Challenges Research Fund spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 2, format: "csv"))
expect(rendered).to have_export_row(report: "Other ODA spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 3, format: "csv"))
expect(rendered).to have_export_row(report: "International Science Partnerships Fund spending breakdown", path: spending_breakdown_exports_organisation_path(organisation, fund_id: 4, format: "csv"))
end
end

Expand Down