Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Vouchers for user promotion - Part 2: Redemption (#671)
* Initialize voucher model and add some unit tests * Make ensure_no_other_active_voucher validation into a callback * Add throw :abort in order to halt execution * Replace Time.now by Time.zone.now * Set up basic functionality for display of vouchers for tutors * Create separate file for copy and paste button code and decaffeinate * Set up destruction of tutor vouchers * Rename view file as it containes embedded ruby * Add create action for vouchers and corresponding views * Adapt views and controller for adding and removing of vouchers of different type * Put duplicate lines into a separate method * Set up redeeming of vouchers * fix typo * remove obsolete methods * Avoid use of Time.now * Refactor active_vouhcer_of_sort method * remove unused expired? method * Remove duplicate code * remove unused variable * Add controller spec for vouchers * Rewrite controller spec for vouchers * remove obsolete comment * Set up redemption of tutor vouchers * Remove user lookup for tutor positions * Set up redemption of editor vouchers * Add Contract Model and setup selection of tutors and editors * Set up notifications for redemption of tutor vouchers * Invalidate vouchers instead of destroying them * Add redemption and claim models and rewrite workflow accordingly * Restore to previous state * Fix typo * Implement Rubocop suggestion * Replace voucher_hash by secure_hash * Replace redeem_voucher_params by check_voucher_params * Add cancel action to vouchers controller * Differentiate between different cases of tutor voucher redemption * Differentiate between different cases of editor voucher redemption * Take first steps in setting up redemption of teacher vouchers * Add notifications for redemption of teacher vouchers * Add notification mails for teacher change by voucher redemption * Invalidate teacher vouchers after first use * Add vouchers for seminar speakers * Add helpdesk for speaker vouchers * Set up redemption of speaker vouchers * Add notifications for redemption of speaker vouchers * Restrict access user select * Remove unused parameter * Introduce VoucherProcessor service object * Use common partial for redemption of tutor and speeaker vouchers * Rename sort attribute of vouchers to role * Rename remaining occurences of sort attribute of voucher to role * Add unit tests for VoucherProcessor * Add .uniq to method * Remove teacher selection for non-admins * Remove obsolete reference to non-existent model * Remove permissions from non-admins to change teachers * Add cypress data attributes * Add first cypress tests * Add more cypress tests * Add first cypress tests for voucher redemption * Init future possibility to check clipboard content * Add missing teacher field for non-admins * Add cypress tests for redemption form * Add cypress command .tomselect to select in TomSelect forms * Add test for redemption form using the new .tomselect command * Remove unnecessary call of trait * Use NO_SEMINAR_ROLES constant * Clean up some experiments * Remove .tomselect Command for cypress * Enlarge test user json by some data * Add logout command and expect correct statuses for login and logout requests * Add more cypress tests for redemption of tutor vouchers * Parse hashes with integer keys into arrays of strings * Add tests for tutor voucher redemption in the case that all tutorials are already taken * Add possibility to pass instance methods and refactor * Update documentation * Add tests for voucher redemption that check notifications * Add missing speaker voucher case * Add missing locales * Add cypress tests fo editor vouchers, teacher vouchers and speaker vouchers * Remove out of scope test * Refactor helper methods * Extract helper functions to separate file * Refactor tests * Extract more methods into helper * Rename files according to conventions * Add controller specs for changed lecture update policy * Refactor tests by extracting methods * Don't define `redeem` method twice Apparently I missed that one during the merge. * Pluralize voucher redemption spec filename * Delete duplicate migration & update new migration dates/schema * Move cypress helpers to e2e folder `support` folder should be used for general test-stuff, i.e. not-related to individual, specific tests. * Improve naming for voucher finding method also moved one private function around * Inline JSON object in user creator controller * Use symbolic keys upon voucher type case statement * Fix "Redeem voucher" spelling mistake * Use fixed width for voucher redemption selectize field * Rename view file to `voucher_redemption_form` * Fix indentation in view file (tutor voucher) * Replace cypress `describe` by `context` * Remove reviewer-TODO comments (selectize tomselect) * Reset Cypress-related code to 49cf16a Command used: git checkout 49cf16a -- ./.vscode/settings.json ./app/controllers/cypress/factories_controller.rb ./app/controllers/cypress/user_creator_controller.rb ./spec/cypress/support/factorybot.js * Use new .call syntax in cypress tests (in order to call instance methods, see #696 * Explicitly set `name_in_tutorials` for users * Remove constraint that user id must be a number This is such that UUIDs also work. * Init support for entity-relationship-diagram creation * Add `has_many :notifications` for better ERD visibility * Remove usage of delegate methods from redemption * Don't hardcode source_type as string * Refactor voucher_processor into model concern According to concepts discussed in #694. Also auto-load subdirectories in models folder and set Current.user for usage in models. * Add missing notification and subscribe lecture steps * Move vouchers down in UI (lecture edit page) * Turn off autocomplete for redeem voucher text field * Strip secure hash to avoid copy-pasting issues with voucher * Improve voucher-model docstrings * Fix wrong permit syntax for arrays * Move Claim model to voucher folder * Adapt Redeemer specs to new architecture Also rename Redeemable to Redeemer to better reflect what it's doing. * Use `pluck` instead of `select` for better performance Also use .uniq just to be sure. * Test timestamp in invalidate! voucher spec * Remove unused routes * Fix missing CSpell configuration * Improve tutor voucher redemption messages also remove unused locale keys * Improve speaker voucher redemption messages * Replace "Voucher" by "Gutschein" in German texts * Improve teacher voucher redemption messages * Improve editor voucher redemption messages * Remove duplicate `no_active_voucher` i18n key * Add help texts to voucher creation * Also eager_load additional modules This is to ensure that `Rails.application.eager_load!` in the rails_erd gem respects all our modules. See this line: https://github.com/voormedia/rails-erd/blob/7c66258b6818c47b4d878c2ad7ff6decebdf834a/lib/rails_erd/tasks.rake#L45 * Outsource x_by_redemption methods from lecture to redemption * Fix wrong i18n controller error The code always errored since the JSON objects are passed as strings from the frontend. * Fix cypress test (due to renaming of i18n keys / html) * Cypress test that whitespaces in voucher hash work * Verify voucher is invalid after user became teacher * Add user deletion cypress spec (for tutor) * Add word to cspell list * Replace "display" by "show" For me, "display" is closer to the frontend, while this is a backend test, that's why I renamed it. Not really that important in the end ;) * Fix two spelling mistakes (out of scope) * Move lecture notifications to separate file * Replace Notifier concern by LectureNotifier module * Remove unused set_recipients method for "new editor mail" * Move email templates to right folder * Correct sender_nad_locale setting * Introduce enqueue_mail_with_params matcher & test for editor * Add spec for Current user model * Inline sender_and_locale * Try to test email sending for editor voucher (fails) * Mock Current model in RSpec tests * Rework sender and locale setting * Fix mail sending test for editor * Test mail body (editor) * Set locale in broader scope test * Fix comment * Test previous and new teacher mail * Use custom html body matcher (ignore \r\n) * Improve wording in html body failure message * Test mails for co-speakers * Ensure user that is now speaker doesn't receive a mail * Use just one file for mail matchers * Rename matcher to enqueue_mail_including_params * Outsource from notification mailer assertion * Refactor send mail to co-speaker test * Remove unwanted test I accidentally added this even though it's not the wanted behavior. * Add tests for teacher selection dropdown * Write test for editor dropdown selection * Allow admin to select any user in lecture editor select * Remove `only` from cypress test * Add more words to spell checker * Add tests for tutor selection dropdown * Add back ability for admin to select any user as tutor * Allow admin to choose arbitrary users as speakers & test * Remove unnecessary display: none * Improve if statement in voucher redemption * Remove another unnecessary "be.visible" statement * Allow admins to select arbitrary users in existing talks & test * Rename lecture spec file * Refactor lecture people select spec (extract methods) * Reuse speaker_select helper * Outsource to new teacher_select helper * Outsource to new editors_select helper * Remove with_seminar trait (since we use the association field now, introduced a few commits beforehand) * Make cypress input selecting more reliable * Remove unnecessary div wrap * Avoid flaky test by intercepting user fill request * Fix cypress not typing "cy" in input box * Remove current_user= test as method was removed * Intercept /talks/new route to avoid flaky test This is due to the form not being completely loaded while we already go on. * Add cy.wait as last resort * Visit #people page directly * Remove unwanted `only` in Cypress test --------- Co-authored-by: Splines <dominic-plein@gmx.de>
- Loading branch information