sto 10fa821f19
All checks were successful
CI / scan_ruby (push) Successful in 17s
CI / scan_js (push) Successful in 12s
CI / lint (push) Successful in 12s
CI / test (push) Successful in 38s
Some contest pages translations
2025-03-27 14:51:25 +01:00

64 lines
1.5 KiB
Ruby

require 'rails_helper'
RSpec.feature "Users", type: :feature do
context "when the user is a regular user" do
let!(:user) { create(:user) }
let!(:contest) { create(:contest, user: user) }
before do
login(user)
end
it "should not see a link to all users" do
visit root_path
expect(page).not_to have_content(I18n.t("nav.users"))
end
it "should not be able to see the user list" do
visit users_path
expect(page).not_to have_content(I18n.t("users.index.title"))
end
it "should be able to create a new contest" do
visit root_path
click_link "Create a new contest"
expect(page).to have_content(I18n.t("contests.new.title"))
end
it "should be able to open an existing contest" do
visit root_path
expect(page).to have_content(contest.name)
find("div.card", text: contest.name).find("a").click
expect(page).to have_content(I18n.t("contests.show.title", name: contest.name))
end
end
context "when the user is an admin" do
let!(:admin) { create(:user, :admin) }
let!(:user) { create(:user) }
before do
login(admin)
end
it "should see a link to all users" do
visit root_path
expect(page).to have_content(I18n.t("nav.users"))
end
it "should be able to see the user list" do
visit users_path
expect(page).to have_content(I18n.t("users.index.title"))
expect(page).to have_content(user.username)
end
end
end