Note version 3.0 removed the `controller` and `request` methods used in component tests, introducing `vc_test_controller` and `vc_test_request` instead. Bumps [view_component](https://github.com/viewcomponent/view_component) from 2.78.0 to 3.5.0. - [Release notes](https://github.com/viewcomponent/view_component/releases) - [Changelog](https://github.com/ViewComponent/view_component/blob/main/docs/CHANGELOG.md) - [Commits](https://github.com/viewcomponent/view_component/compare/v2.78.0...v3.5.0) --- updated-dependencies: - dependency-name: view_component dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
54 lines
2.2 KiB
Ruby
54 lines
2.2 KiB
Ruby
require "rails_helper"
|
|
|
|
describe Budgets::Ballot::BallotComponent do
|
|
include Rails.application.routes.url_helpers
|
|
before { vc_test_request.session[:ballot_referer] = "/" }
|
|
|
|
describe "link to group" do
|
|
let(:budget) { create(:budget, :balloting) }
|
|
let(:group) { create(:budget_group, budget: budget) }
|
|
let(:ballot) { create(:budget_ballot, user: create(:user), budget: budget) }
|
|
|
|
context "group with a single heading" do
|
|
let!(:heading) { create(:budget_heading, group: group, price: 1000) }
|
|
|
|
it "displays a link to vote investments when there aren't any investments in the ballot" do
|
|
render_inline Budgets::Ballot::BallotComponent.new(ballot)
|
|
|
|
expect(page).to have_link "You have not voted on this group yet, go vote!",
|
|
href: budget_investments_path(budget, heading_id: heading.id)
|
|
end
|
|
|
|
it "displays a link to continue voting when there are investments in the ballot" do
|
|
ballot.investments << create(:budget_investment, :selected, heading: heading, price: 200)
|
|
|
|
render_inline Budgets::Ballot::BallotComponent.new(ballot)
|
|
|
|
expect(page).to have_link "Still available to you €800",
|
|
href: budget_investments_path(budget, heading_id: heading.id)
|
|
end
|
|
end
|
|
|
|
context "group with multiple headings" do
|
|
let!(:heading) { create(:budget_heading, group: group, price: 1000) }
|
|
before { create(:budget_heading, group: group) }
|
|
|
|
it "displays a link to vote on a heading when there aren't any investments in the ballot" do
|
|
render_inline Budgets::Ballot::BallotComponent.new(ballot)
|
|
|
|
expect(page).to have_link "You have not voted on this group yet, go vote!",
|
|
href: budget_group_path(budget, group)
|
|
end
|
|
|
|
it "displays a link to change the heading when there are invesments in the ballot" do
|
|
ballot.investments << create(:budget_investment, :selected, heading: heading, price: 200)
|
|
|
|
render_inline Budgets::Ballot::BallotComponent.new(ballot)
|
|
|
|
expect(page).to have_link "Still available to you €800",
|
|
href: budget_group_path(budget, group)
|
|
end
|
|
end
|
|
end
|
|
end
|