Commit Graph

6149 Commits

Author SHA1 Message Date
Javi Martín
1b9d321c4e Extract methods in poll status component
This way we remove duplication in the HTML.

We're also adding a test checking what happens when users can vote in
order to test the `render?` method we've added.
2025-08-22 13:09:49 +02:00
Javi Martín
b2a49cd291 Extract component to render the status of a poll
We're renaming the existing HTML class in order to be consistent with
the name of the component.
2025-08-22 12:13:41 +02:00
Javi Martín
8deb1964bd Show errors when submitting too many answers
This could be the case when JavaScript is disabled.

Note that, in `Poll/WebVote` we're calling `given_answers` inside a
transaction. Putting this code before the transaction resulted in a test
failing sometimes, probably because of a bug that might be possible to
reproduce by doing simultaneous requests.
2025-08-14 13:06:43 +02:00
werdenktwas-gmbh
abf02808bf Disable other answers when reaching maximum votes
This is similar to the way we were disabling buttons in the old design.

Co-authored-by: Javi Martín <javim@elretirao.net>
2025-08-14 13:06:43 +02:00
Javi Martín
7ea4f63b07 Allow blank votes in polls via web
With the old interface, there wasn't a clear way to send a blank ballot.
But now that we've got a form, there's an easy way: clicking on "Vote"
while leaving the form blank.
2025-08-14 13:06:43 +02:00
Javi Martín
5402cb6042 Move poll callout partial to a component
This way it'll be easier to refactor it.

Note there was a system test which tested both the callout and the form
when unverified users visit a poll. We've split this system test in two
component tests.
2025-08-14 13:06:43 +02:00
Javi Martín
a7e1b42b6c Use checkboxes and radio buttons on poll forms
Our original interface to vote in a poll had a few issues:

* Since there was no button to send the form, it wasn't clear that
  selecting an option would automatically store it in the database.
* The interface was almost identical for single-choice questions and
  multiple-choice questions, which made it hard to know which type of
  question we were answering.
* Adding other type of questions, like open answers, was hard since we
  would have to add a different submit button for each answer.

So we're now using radio buttons for single-choice questions and
checkboxes for multiple-choice questions, which are the native controls
designed for these purposes, and a button to send the whole form.

Since we don't have a database table for poll ballots like we have for
budget ballots, we're adding a new `Poll::WebVote` model to manage poll
ballots. We're using WebVote instead of Ballot or Vote because they
could be mistaken with other vote classes.

Note that browsers don't allow removing answers with radio buttons, so
once somebody has voted in a single-choice question, they can't remove
the vote unless they manually edit their HTML. This is the same behavior
we had before commit 7df0e9a96.

As mentioned in c2010f975, we're now adding the `ChangeByZero` rubocop
rule, since we've removed the test that used `and change`.
2025-08-14 13:06:37 +02:00
Javi Martín
fd14c55615 Make answer depend on the option in poll answer factory
Until now, when writing `create(:poll_answer, option: option)`, the
`answer` field would take the title of a random option instead of taking
the title from the `option` variable.

So now, if we're given the option, the `answer` field will be taken from
the option itself.

Note that writing something like:

```
option { question.question_options.find_by(title: answer) }
answer { option.title }
```

Would create an infinite loop when creating a poll answer if we don't
pass the `option` and/or the `answer` attributes.

So, instead, we're making the `option` depend on the `answer` attribute
exclusively when we pass the `answer` attribute to the factory.
2025-08-14 12:58:51 +02:00
Javi Martín
a5054089b8 Fix typo in poll voter test 2025-08-12 12:45:12 +02:00
Javi Martín
6c5b908ef5 Use a loop instead of with_collection to render questions
This is what we usually do in components.
2025-08-12 12:45:12 +02:00
Anamika Aggarwal
c9bf7797a0 Add multi-tenancy support for SAML 2025-07-23 14:43:45 +02:00
taitus
a4709f9da0 Add omniauth saml section for sign in and sign up page
Co-authored-by: Anamika Aggarwal <anamikaagg18@gmail.com>
2025-07-23 14:43:44 +02:00
Sebastia
f4189365ea Merge pull request #5955 from cyrillefr/ReplaceLinkWithButtonInVariousComponentsPartI
Replace link with button in various components part i
2025-07-09 15:26:38 +02:00
cyrillefr
f0e696b972 Replace link with button in letter verification 2025-07-09 13:48:58 +02:00
cyrillefr
c989210e74 Replace link with button in finish signup in registrations 2025-07-09 13:48:58 +02:00
cyrillefr
3eba2d27a4 Replace link with button in Topics show 2025-07-09 13:48:58 +02:00
cyrillefr
50076504b5 Replace link with button in flag unflag actions 2025-07-09 13:48:58 +02:00
cyrillefr
a6046155a2 Replace link with button in relationable scores 2025-07-09 13:48:58 +02:00
cyrillefr
d4b7939d2c Replace link with button in Proposal created 2025-07-09 13:48:58 +02:00
cyrillefr
ddd34d5cd0 Replace link with button in index notifications 2025-07-09 13:48:58 +02:00
cyrillefr
75ed7ae3ef Replace link with button in nofications 2025-07-09 13:48:58 +02:00
cyrillefr
267dd931d8 Replace link with button in change user link 2025-07-09 13:48:58 +02:00
cyrillefr
e370a52650 Replace link with buttons in follow button 2025-07-09 13:48:58 +02:00
cyrillefr
31ceb31256 Replace link with button in Dashboard show 2025-07-03 11:14:53 +02:00
dependabot[bot]
123c97771a Bump rubocop from 1.71.2 to 1.75.8
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.71.2 to 1.75.8.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.71.2...v1.75.8)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-version: 1.75.8
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Notes:

This commit also includes several style and lint fixes required after
updating RuboCop:

- Removed redundant parentheses now detected by improved
  'Style/RedundantParentheses' (1.72 and 1.75.3).
- Replaced ternary expressions with logical OR when the ternary was
  returning 'true', as flagged by 'Style/RedundantCondition' (1.73).
- Adjusted block variables to resolve new 'Lint/ShadowingOuterLocalVariable'
  offenses (1.75), helping avoid future conflicts during upgrades with
  'rails app:updates'

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-16 16:07:32 +02:00
taitus
b8583f2eae Move shared imageable specs to nested imageable specs file
In order to unify all related tests with imageable, we move shared imageable
specs and remove that file.
2025-06-12 09:14:38 +02:00
Sebastia
7d6bf0589d Merge pull request #5989 from consuldemocracy/nested-documentable-specs
Make nested documentable specs faster
2025-06-10 09:30:18 +02:00
taitus
49facdca7d Refactor nested document tests to simplify contexts and remove duplication 2025-06-09 17:35:40 +02:00
taitus
44cfb9bcc2 Unify lets from documentable and imageable to attachables methods 2025-06-09 17:35:40 +02:00
taitus
472e244103 Move tests related with attached documents from documentable shared specs to nested documentable file
Note that we moved some system tests to component tests, since they don't involve user interaction and can
be fully covered at the component level.
2025-06-09 17:32:41 +02:00
taitus
7a317ef9c1 Unify and move documentable shared specs to nested documentable file 2025-06-09 15:23:59 +02:00
taitus
11f09c281c Move test for check metadata to nested documentable system 2025-06-09 15:23:59 +02:00
taitus
9e805d95de Unify tests from "Only for edit path" describe in order to reduce duplicated code 2025-06-09 15:23:59 +02:00
taitus
2420f27704 Unify tests when removing documents 2025-06-09 15:23:59 +02:00
taitus
59c61d02cc Remove redundant tests from "Only for edit path" describe
These tests already tested in previous tests.
2025-06-06 17:18:15 +02:00
taitus
28e9832c40 Unify tests in order to remove duplicated code
Note that we are removing a specific "context" that can be replaced
with an "if" in the previous spec.
2025-06-06 17:18:15 +02:00
taitus
b7025a8135 Remove "outdated" comment
Since commit 23682fadd8, we have had the comment:
> # Review
> # Doble check why the file is stored with a name different to empty.pdf

This might be outdated.
2025-06-06 17:18:15 +02:00
taitus
afdf65dec9 Remove unnecessary tests and expectations related with loading-bar
These expectations are already covered by attach_new_file, so they are no longer needed:
>  expect(page).to have_css ".loading-bar.complete"

We can remove the tests:
> "Should update loading bar style after invalid file upload"
because the expectation:
> expect(page).to have_css ".loading-bar.errors"
It is already tested in "Should not update document cached_attachment field after invalid file upload"
2025-06-06 17:18:15 +02:00
taitus
88ba548343 Unify fill_in field in one line 2025-06-06 17:18:15 +02:00
taitus
e6089c2b63 Remove expect_document_has_title method
I think tests are now clearer by using have_field.

Note that I have remove the within ".document-fields" because there is
only one document.
2025-06-06 17:18:15 +02:00
taitus
d7581955f8 Remove duplicated code in imageable and documentable attach file methods 2025-06-06 17:18:15 +02:00
taitus
82296a33e2 Use documentable_attach_new_file method where possible
Use this commit to unify two similar specs.
2025-06-06 17:18:15 +02:00
taitus
64c1c59a7a Unify tests related with shows or hides max documents warning 2025-06-06 17:18:15 +02:00
taitus
a4e7b70227 Unify tests related with shows or hides new document link 2025-06-06 17:18:15 +02:00
taitus
82dac1225c Simplify tests by setting "max documents allowed" to 1
Note that this commit also applies a similar change to the
imageable_attach_new_file method by removing an unnecessary variable.

In order to testing with more than 1 max documents allowed we
keep one test with this value.
2025-06-06 17:18:15 +02:00
taitus
addda0c773 Unify duplicated methods in common_actions folder
Replaced the user with a level_two one in the "Default whole city" test to
bypass the full name requirement, which only applies to unverified users.
2025-06-06 17:07:50 +02:00
taitus
2cc23309b8 Unify attachables methods 2025-06-06 16:00:16 +02:00
taitus
e7c5b03d8c Extract edit proposals from shared nested documentable to system specs
We can remove shared nested documentable file because has not references.
2025-06-06 16:00:15 +02:00
taitus
979171ec45 Extract proposals from shared nested documentable to system specs
Removed the now-unused 'documentable_fill_new_valid_proposal' method
from common actions.

Note that it does not seem necessary to create an administrator with the user, as was
done in the original shared example. Also, as in the previous commit, it appears that
we do not need to set the user as the author when creating the documentable.

Also removed the documentable_redirected_to_resource_show_or_navigate_to method,
which was only used for the :proposal factory but was not necessary.
- In the "Proposal new" case (this commit), after submitting the form we are
redirected to the "created" page, where the link "Not now, go to my proposal"
does not appear. This caused the method to always raise a
Capybara::ElementNotFound and return nil.

Instead, this "created" page already displays a preview of the proposal
and a link to publish it. Since we can verify that the proposal was created
successfully here, no redirection or click is needed.

- In the "Proposal edit" case (next commit), the user is redirected directly
to the proposal's "show" page after update, so again, the method is
unnecessary and has been removed.
2025-06-06 15:56:27 +02:00
taitus
12c1d77061 Extract management_budget_investment from shared nested documentable spec to system specs
Replaced 'login_as' with 'do_login_for' using 'management: management_section?' to
handle login requirements correctly for each context.

Also removed the now-unused 'documentable_fill_new_valid_budget_investment' helper
from common actions.

Note that it does not seem necessary to create an administrator with the user, as was
done in the original shared example. Also, as in the previous commit, it appears that
we do not need to set the user as the author when creating the documentable.

While reviewing this, we also noticed that the create(:administrator, user: user) call
was unnecessarily included in the nested_imageable system spec in commit cdfaec5217 when
the path is a management section. So we use this commit to remove the unnecessary condition.
2025-06-06 15:56:27 +02:00