Upstream sync

This commit is contained in:
Senad Uka
2020-06-18 16:56:11 +02:00
parent a7b90c223b
commit 1168bcdfdd
11 changed files with 96 additions and 16 deletions

View File

@@ -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