Upstream sync
This commit is contained in:
@@ -128,6 +128,26 @@ RSpec.describe Api::BroadcastsController, type: :controller do
|
||||
expect(included.first.dig("id")).to eq broadcast.files.first.id.to_s
|
||||
expect(included.first.dig("type")).to eq 'active_storage_attachment'
|
||||
end
|
||||
|
||||
context "when files param contains a signed_id string" do
|
||||
it "adds that file to the broadcast" do
|
||||
project = create(:project, name: 'first', account_id: current_user.primary_account.id)
|
||||
broadcast = create(:broadcast, :with_stream, skip_create_callback: true, project: project, status: 'created')
|
||||
blob = ActiveStorage::Blob.create_after_upload!(io: StringIO.new("Hello"), filename: "hello.txt", content_type: "text/plain")
|
||||
|
||||
sign_in_to_api(current_user)
|
||||
patch :update, params: { project_id: project, id: broadcast, broadcast: { files: [blob.signed_id] } }
|
||||
|
||||
relationships = JSON.parse(response.body).dig('data', 'relationships')
|
||||
included = JSON.parse(response.body).dig('included')
|
||||
|
||||
expect(relationships.keys).to include('files')
|
||||
expect(included.size).to eq 1
|
||||
expect(included.first.dig("id")).to eq broadcast.files.first.id.to_s
|
||||
expect(included.first.dig("type")).to eq 'active_storage_attachment'
|
||||
expect(included.first.dig("attributes", "filename")).to eq 'hello.txt'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
after do
|
||||
|
||||
Reference in New Issue
Block a user