2023-10-13 23:42:17 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe "Root path", type: :request do
|
|
|
|
describe "GET /" do
|
|
|
|
it "works! (now write some real specs)" do
|
|
|
|
get root_path
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
2023-10-22 19:03:45 +00:00
|
|
|
|
|
|
|
it "should have a link to the dictionary" do
|
|
|
|
get root_path
|
|
|
|
expect(response.body).to have_selector(%(a[href="#{dictionary_index_path}"]))
|
|
|
|
end
|
2023-10-13 23:42:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "logged out" do
|
|
|
|
it "should have 'Register' link" do
|
|
|
|
get root_path
|
|
|
|
expect(response.body).to include("Register")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "logged in" do
|
|
|
|
it "should have 'Sign Out' link" do
|
|
|
|
sign_in FactoryBot.create(:user)
|
|
|
|
get root_path
|
|
|
|
expect(response.body).to include("Sign Out")
|
|
|
|
end
|
|
|
|
|
2023-10-25 03:47:01 +00:00
|
|
|
it "should have the 'Languages' link" do
|
|
|
|
sign_in FactoryBot.create(:user)
|
|
|
|
get root_path
|
2023-10-25 20:25:29 +00:00
|
|
|
expect(response.body).to have_selector(%(a[href="#{admin_languages_path}"]))
|
2023-10-25 03:47:01 +00:00
|
|
|
end
|
|
|
|
|
2023-10-13 23:42:17 +00:00
|
|
|
it "should welcome user by username" do
|
|
|
|
user = FactoryBot.create(:user)
|
|
|
|
sign_in user
|
|
|
|
get root_path
|
|
|
|
expect(response.body).to include(user.username)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|