@@ -30,5 +30,7 @@
|
|||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :contest do
|
factory :contest do
|
||||||
name { Faker::Company.unique.name }
|
name { Faker::Company.unique.name }
|
||||||
|
duration { "2:00" }
|
||||||
|
ranking_mode { "actual" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ RSpec.feature "Contests", type: :feature do
|
|||||||
|
|
||||||
find(".stretched-link[href=\"/contests/#{first_contest.friendly_id}\"]").click
|
find(".stretched-link[href=\"/contests/#{first_contest.friendly_id}\"]").click
|
||||||
|
|
||||||
expect(page).to have_current_path("/contests/#{first_contest.friendly_id}")
|
expect(page).to have_current_path("/contests/#{first_contest.friendly_id}/contestants")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should offer to create a new contest" do
|
it "should offer to create a new contest" do
|
||||||
@@ -48,31 +48,7 @@ RSpec.feature "Contests", type: :feature do
|
|||||||
|
|
||||||
click_button I18n.t("helpers.buttons.create")
|
click_button I18n.t("helpers.buttons.create")
|
||||||
|
|
||||||
expect(page).to have_current_path(contest_path(Contest.find_by(name: "Contest name")))
|
expect(page).to have_current_path("/contests")
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "edit" do
|
|
||||||
let!(:contest) { create(:contest, user: user) }
|
|
||||||
|
|
||||||
it "should prevent editing contests without a name" do
|
|
||||||
visit edit_contest_path(contest)
|
|
||||||
|
|
||||||
fill_in I18n.t("activerecord.attributes.contest.name"), with: ""
|
|
||||||
|
|
||||||
click_button I18n.t("helpers.buttons.save")
|
|
||||||
|
|
||||||
expect(page).to have_content(I18n.t("activerecord.errors.models.contest.attributes.name.blank"))
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should allow editing contests with valid parameters" do
|
|
||||||
visit edit_contest_path(contest)
|
|
||||||
|
|
||||||
fill_in I18n.t("activerecord.attributes.contest.name"), with: "Contest name"
|
|
||||||
|
|
||||||
click_button I18n.t("helpers.buttons.save")
|
|
||||||
|
|
||||||
expect(page).to have_current_path(contest_path(contest))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ RSpec.feature "Login", type: :feature do
|
|||||||
fill_in "Password", with: user.password
|
fill_in "Password", with: user.password
|
||||||
click_button "Sign in"
|
click_button "Sign in"
|
||||||
|
|
||||||
expect(page).to have_content(I18n.t("sessions.new.title"))
|
expect(page).to have_content("Puzzle scoreboard")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should fail to log in the user with an incorrect password" do
|
it "should fail to log in the user with an incorrect password" do
|
||||||
@@ -28,7 +28,7 @@ RSpec.feature "Login", type: :feature do
|
|||||||
fill_in "Password", with: Faker::Internet.unique.password
|
fill_in "Password", with: Faker::Internet.unique.password
|
||||||
click_button "Sign in"
|
click_button "Sign in"
|
||||||
|
|
||||||
expect(page).to have_content(I18n.t("sessions.new.title"))
|
expect(page).to have_content("Puzzle scoreboard")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user