2017-08-14 14:34:04 -06:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe DashboardController do
|
|
|
|
include Devise::Test::ControllerHelpers
|
2018-03-01 09:21:53 -07:00
|
|
|
let(:user) { FactoryBot.create(:user, confirmed_at: nil) }
|
2017-08-14 14:34:04 -06:00
|
|
|
|
2018-01-20 10:17:20 -07:00
|
|
|
describe 'dashboard endpoint' do
|
2017-09-01 13:58:24 -06:00
|
|
|
it "renders the terms of service" do
|
2017-09-01 14:13:37 -06:00
|
|
|
get :tos_update
|
2017-09-01 13:58:24 -06:00
|
|
|
expect(response.status).to eq(200)
|
2017-09-20 09:26:48 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
it "renders the terms of service" do
|
|
|
|
get :front_page
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "renders the terms of service" do
|
|
|
|
expect { get :main_app, params: {path: "nope.jpg"} }
|
|
|
|
.to raise_error(ActionController::RoutingError)
|
2017-09-01 13:58:24 -06:00
|
|
|
end
|
2018-01-13 09:12:28 -07:00
|
|
|
|
|
|
|
it "receives CSP violation reports (malformed JSON)" do
|
2018-09-27 15:10:17 -06:00
|
|
|
expect(Rollbar).to receive(:info)
|
|
|
|
.with("CSP Violation", {problem: "Crashed while parsing report"})
|
2018-01-13 09:12:28 -07:00
|
|
|
post :csp_reports, body: "NOT JSON ! ! !"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "receives CSP violation reports (malformed JSON)" do
|
2018-09-27 15:10:17 -06:00
|
|
|
expect(Rollbar).to receive(:info)
|
|
|
|
.with("CSP Violation", {})
|
2018-01-13 09:12:28 -07:00
|
|
|
post :csp_reports, body: {}.to_json, params: {format: :json}
|
|
|
|
end
|
2018-03-01 09:21:53 -07:00
|
|
|
|
|
|
|
it 'creates a new user' do
|
|
|
|
params = { token: user.confirmation_token }
|
|
|
|
expect(user.confirmed_at).to eq(nil)
|
|
|
|
get :verify, params: params
|
|
|
|
user.reload
|
2018-03-18 09:23:00 -06:00
|
|
|
expect(user.confirmation_token).to be
|
2018-03-01 09:21:53 -07:00
|
|
|
expect(user.confirmed_at).to be
|
|
|
|
expect(user.confirmed_at - Time.now).to be < 3
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'verifies email changes' do
|
|
|
|
email = "foo@bar.com"
|
|
|
|
user.update_attributes!(unconfirmed_email: "foo@bar.com")
|
|
|
|
params = { token: user.confirmation_token }
|
|
|
|
get :verify, params: params
|
|
|
|
expect(user.reload.unconfirmed_email).to be nil
|
|
|
|
expect(user.email).to eq email
|
|
|
|
end
|
2018-05-04 12:26:53 -06:00
|
|
|
|
|
|
|
it 'handles self hosted image uploads' do
|
|
|
|
name = "wow.jpg"
|
|
|
|
params = {key: "whatever/" + name,
|
|
|
|
file: StringIO.new(File.open("./spec/fixture.jpg").read)}
|
|
|
|
post :direct_upload, params: params
|
|
|
|
file = File.join("public", "direct_upload", "temp", name)
|
|
|
|
expect(File.file?(file)).to be(true)
|
2018-12-21 14:11:47 -07:00
|
|
|
expect(response.status).to eq(200)
|
2018-05-04 12:26:53 -06:00
|
|
|
File.delete(file)
|
|
|
|
end
|
2017-08-14 14:34:04 -06:00
|
|
|
end
|
|
|
|
end
|