docbrown/spec/requests/videos_spec.rb
rhymes e588fa7ece Code cleanups (#659)
* Initial automatic cleanup with rubocop

* Fix syntax error introduced by rubocop

* Cleanup seeds file

* Cleanup lib folder

* Exclude bin folder because it contains auto generated files

* Make Rubocop a little bit more chatty

* Block length should not include comments in the count

* Cleanup config folder

* Cleanup specs

* Updated Rubocop version and generated a todo file

* Fix broken ArticlesApi spec

* Fix tests

* Restored rubocop pre-commit hook
2018-08-07 11:00:13 -04:00

56 lines
1.4 KiB
Ruby

require "rails_helper"
RSpec.describe "Videos", type: :request do
let(:unauthorized_user) { create(:user) }
let(:authorized_user) { create(:user, :video_permission) }
describe "GET /videos/new" do
context "when not authorized" do
it "redirects non-logged in users" do
expect { get "/videos/new" }.to raise_error(Pundit::NotAuthorizedError)
end
it "redirects logged in users" do
login_as unauthorized_user
expect { get "/videos/new" }.to raise_error(Pundit::NotAuthorizedError)
end
end
context "when authorized" do
it "allows authorized users" do
login_as authorized_user
get "/videos/new"
expect(response.body).to include "Upload Video File"
end
end
end
describe "POST /videos" do
context "when not authorized" do
it "redirects non-logged in users" do
expect { post "/videos" }.to raise_error(Pundit::NotAuthorizedError)
end
it "redirects logged in users" do
login_as unauthorized_user
expect { post "/videos" }.to raise_error(Pundit::NotAuthorizedError)
end
end
context "when authorized" do
before do
login_as authorized_user
end
valid_params = {
article: {
video: "something.mp4",
},
}
xit "creates an article for the logged in user" do
post "/videos", params: valid_params
end
end
end
end