docbrown/spec/requests/video_states_update_spec.rb
Michael Kohl 6dfabd578f
Rename SiteConfig to Settings::General (#13573)
* Rename SiteConfig

* More renaming

* Update spec

* Update mandatory settings mapping

* More renaming

* e2e test fixes

* You have a rename, and you have a rename

* Spec fix

* More changes

* Temporarily disable specs

* After-merge update

* Undo rename for migration

* undo rename of DUS

* Fix DUS

* Fix merge problem

* Remove redundant DUS

* Fix specs

* Remove unused code

* Change wrong class name

* More cleanup

* Re-add missing values to constant

* Fix constant

* Fix spec

* Remove obsolete fields

* Add accidentally removed field

* Update spec

* Move methods from Settings::General to ForemInstance

* Remove unneeded model

* Change mentions of 'site config'
2021-05-21 14:45:37 +02:00

33 lines
1.1 KiB
Ruby

require "rails_helper"
RSpec.describe "VideoStatesUpdate", type: :request do
let(:encoder_key) { "TEST_SECRET" }
let(:article) { create(:article, video_code: "DUMMY_VID_CODE") }
before do
allow(Settings::General).to receive(:video_encoder_key).and_return(encoder_key)
end
describe "POST /video_states" do
it "updates video state" do
input = JSON.unparse(input: { key: article.video_code })
post "/video_states?key=#{encoder_key}",
params: { Message: input }.to_json
expect(Article.last.video_state).to eq("COMPLETED")
end
it "rejects invalid key" do
post "/video_states?key=not_a_valid_key",
params: { input: { key: article.video_code } }
expect(response).to have_http_status(:unprocessable_entity)
end
it "returns not_found if video article is not found" do
input = JSON.unparse(input: { key: "abc" })
post "/video_states?key=#{encoder_key}",
params: { Message: input }.to_json
expect(response).to have_http_status(:not_found)
expect(response.parsed_body["message"]).to eq("Related article not found")
end
end
end