Skip to content

Commit

Permalink
Give variables meaningful names
Browse files Browse the repository at this point in the history
This fixes the rubocop failure `RSpec/IndexedLet`.
  • Loading branch information
brucebolt committed Jun 27, 2024
1 parent ee7b9a8 commit 7d641b7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions spec/lib/asset_processor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
let(:output) { StringIO.new }
let(:report_progress_every) { 1 }

let!(:asset_1) { FactoryBot.create(:asset) }
let!(:asset_2) { FactoryBot.create(:asset) }
let!(:first_asset) { FactoryBot.create(:asset) }
let!(:second_asset) { FactoryBot.create(:asset) }

it "iterates over all assets" do
asset_ids = []
processor.process_all_assets_with do |asset_id|
asset_ids << asset_id
end
expect(asset_ids).to contain_exactly(asset_1.id.to_s, asset_2.id.to_s)
expect(asset_ids).to contain_exactly(first_asset.id.to_s, second_asset.id.to_s)
end

it "reports progress for every asset" do
Expand Down
16 changes: 8 additions & 8 deletions spec/requests/access_limited_assets_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require "rails_helper"

RSpec.describe "Access limited assets", type: :request do
let(:user_1) { FactoryBot.create(:user, uid: "user-1-id") }
let(:user_2) { FactoryBot.create(:user, uid: "user-2-id") }
let(:user_3) { FactoryBot.create(:user, uid: "user-3-id", organisation_content_id: "org-a") }
let(:user_4) { FactoryBot.create(:user, uid: "user-4-id", organisation_content_id: "org-b") }
let(:authorised_user) { FactoryBot.create(:user, uid: "user-1-id") }
let(:unauthorised_user) { FactoryBot.create(:user, uid: "user-2-id") }
let(:user_from_authorised_organisation) { FactoryBot.create(:user, uid: "user-3-id", organisation_content_id: "org-a") }
let(:user_from_unauthorised_organisation) { FactoryBot.create(:user, uid: "user-4-id", organisation_content_id: "org-b") }
let(:asset) { FactoryBot.create(:uploaded_asset, draft: true, access_limited: ["user-1-id"], access_limited_organisation_ids: %w[org-a]) }
let(:s3) { S3Configuration.build }

Expand All @@ -15,31 +15,31 @@
end

it "are accessible to users who are authorised to view them" do
login_as user_1
login_as authorised_user

get download_media_path(id: asset, filename: asset.filename)

expect(response).to be_successful
end

it "are not accessible to users who are not authorised to view them" do
login_as user_2
login_as unauthorised_user

get download_media_path(id: asset, filename: asset.filename)

expect(response).to be_forbidden
end

it "are accessible to users in organisations authorised to view them" do
login_as user_3
login_as user_from_authorised_organisation

get download_media_path(id: asset, filename: asset.filename)

expect(response).to be_successful
end

it "are not accessible to users in organisations not authorised to view them" do
login_as user_4
login_as user_from_unauthorised_organisation

get download_media_path(id: asset, filename: asset.filename)

Expand Down
8 changes: 4 additions & 4 deletions spec/requests/access_limited_whitehall_assets_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require "rails_helper"

RSpec.describe "Access limited Whitehall assets", type: :request do
let(:user_1) { FactoryBot.create(:user, uid: "user-1-id") }
let(:user_2) { FactoryBot.create(:user, uid: "user-2-id") }
let(:authorised_user) { FactoryBot.create(:user, uid: "user-1-id") }
let(:unauthorised_user) { FactoryBot.create(:user, uid: "user-2-id") }
let(:asset) { FactoryBot.create(:uploaded_whitehall_asset, draft: true, access_limited: ["user-1-id"]) }
let(:s3) { S3Configuration.build }

Expand All @@ -13,15 +13,15 @@
end

it "are accessible to users who are authorised to view them" do
login_as user_1
login_as authorised_user

get asset.legacy_url_path

expect(response).to be_successful
end

it "are not accessible to users who are not authorised to view them" do
login_as user_2
login_as unauthorised_user

get asset.legacy_url_path

Expand Down

0 comments on commit 7d641b7

Please sign in to comment.