Top Level Namespace

Defined Under Namespace

Modules: Decidim

Instance Method Summary collapse

Instance Method Details

#do_action(action) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/decidim/elections/test/vote_controller_examples.rb', line 3

def do_action(action)
  if [:show, :confirm, :waiting, :receipt].include?(action)
    get action, params: params
  else
    patch action, params: params
  end
end

#fill_in_votesObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/decidim/elections/test/vote_examples.rb', line 22

def fill_in_votes
  expect(page).to have_current_path(election_vote_path(election.questions.first))
  expect(page).to have_content(translated_attribute(election.questions.first.body))
  expect(page).to have_content(strip_tags(translated_attribute(election.questions.first.description)))
  choose translated_attribute(election.questions.first.response_options.first.body)
  click_on "Next"
  expect(page).to have_current_path(election_vote_path(election.questions.second))
  expect(page).to have_content(translated_attribute(election.questions.second.body))
  expect(page).to have_content(strip_tags(translated_attribute(election.questions.second.description)))
  check translated_attribute(election.questions.second.response_options.first.body)
  check translated_attribute(election.questions.second.response_options.second.body)
  click_on "Next"
  expect(page).to have_current_path(confirm_election_votes_path)
  expect(page).to have_content("Confirm your vote")
  expect(page).to have_content(translated_attribute(election.questions.first.body))
  expect(page).to have_content(translated_attribute(election.questions.first.response_options.first.body))
  expect(page).to have_no_content(translated_attribute(election.questions.first.response_options.second.body))
  expect(page).to have_content(translated_attribute(election.questions.second.body))
  expect(page).to have_content(translated_attribute(election.questions.second.response_options.first.body))
  expect(page).to have_content(translated_attribute(election.questions.second.response_options.second.body))
  click_on "Cast vote"
  expect(page).to have_content("Your vote has been successfully cast.")
  click_on "Exit the voting booth"
  expect(page).to have_current_path(election_path)
  expect(page).to have_content("You have already voted.")
  expect(election.votes.where(voter_uid: voter_uid).size).to eq(3)
end