docbrown/spec/requests/editor_spec.rb
Lisa Sy 5ff2ad7437
Update main authentication view to improve visual design (#9856) [deploy]
* Update mobile version of /new registration view

* Optimize styles for desktop view

* Fix typo

* Fix typo

* Add twemojis in footer area

* Update messaging to fulfill all intents

* cache

* cache

* hr-label fix on mobile

* hr-label fix on mobile

* crayons for checkbox

* crayons for checkbox

* remove old styles

* move signin to appropriate folder

* Remove schema changes

* Fix registraction specs and hide password hint for no SSO enabled

* Disable email hint for password reset page

* Fix specs

* Revert "Disable email hint for password reset page"

This reverts commit b33a6dda4c13534541294281f83f7ad5a4864c0d.

* Transfer User.registered.estimated_count to the controller

* Fix import path

Co-authored-by: ludwiczakpawel <ludwiczakpawel@gmail.com>
Co-authored-by: rhymes <rhymes@hey.com>
2020-08-31 09:55:27 -07:00

55 lines
1.4 KiB
Ruby

require "rails_helper"
RSpec.describe "Editor", type: :request do
describe "GET /new" do
context "when not logged-in" do
it "asks the non logged in user to sign in" do
get new_path
expect(response).to have_http_status(:ok)
expect(response.body).to include("Password")
end
end
end
describe "GET /:article/edit" do
let(:user) { create(:user) }
let(:article) { create(:article, user: user) }
context "when not logged-in" do
it "redirects to /enter" do
get "/username/article/edit"
expect(response).to redirect_to("/enter")
end
end
context "when logged-in" do
it "render markdown form" do
sign_in user
get "/#{user.username}/#{article.slug}/edit"
expect(response).to have_http_status(:ok)
end
end
end
describe "POST /articles/preview" do
let(:user) { create(:user) }
let(:article) { create(:article, user: user) }
let(:headers) { { "Content-Type": "application/json", Accept: "application/json" } }
context "when not logged-in" do
it "redirects to /enter" do
post "/articles/preview", headers: headers
expect(response).to have_http_status(:unauthorized)
end
end
context "when logged-in" do
it "returns json" do
sign_in user
post "/articles/preview", headers: headers
expect(response.media_type).to eq("application/json")
end
end
end
end