tansaku/LocalSupport — pull request #201 by johnnymo87 (2014-03-02 07:21:01+00:00)
Title: Devise invitable

**Summary:** The invite process has been overhauled to integrate the devise invitable gem. We now have automatic invite emails, a custom invite landing page, and custom navigation after that.

**TODO**
* Extract `without_users_create` to its own `InvitationsController`
* Extract the `without_users` table into a partial, so it can be used to make a table for invited users (so re-invites can be sent)
* Apply the same table format to the pending users table
* Make table views to display all orgs and all users?

**Explanation by file:**
* `Gemfile`: gem version locked because our `devise` [version is not >= 3.1.0](https://github.com/scambra/devise_invitable#deviseinvitable)
* `without_users.js`:
* `generate_users` renamed to `invite_users`
* now seeks for a hidden field (regarding resending invitations) in view, relays that in post request
* now sends an array of `{id: 'email'}` hashes rather than just an array of ids
* `application_controller.rb`: includes a redirect hook for after a user accepts her invitation and sets her password, sending them to her organization
* `organization_reports_controller.rb`:
* `without_users_index` now sends a boolean flag for disallowing re-invites
* `without_users_create` iterates over the array of `{id: 'email'}` hashes, calling passing each to the `UserInviter` service and building a response array of `{id: 'response message'}` hashes
* `organization.rb`: discards a now unused scope
* `user.rb`:
* includes devise invitable module
* monkey patches `accept_invitation!` from devise invitable so that users get "email matched" with organizations when they accept their invitations
* `message_for_invite` is an extract of invite response logic
* `resend_invitation_enabler.rb`: a service to tell the dependency to enable/disable re-invites
* `user_inviter.rb`: a service to tell the dependency to invite a given user
* `invitations/edit.html.erb`: the landing page when the user accepts her invite
* `invitations/new.html.erb`: unused scaffolding, but could be used to expose the invite functionality to more users.
* `mailer/invitation_instructions.html.erb`: boilerplate invitation email
* `without_users_index.html.erb`:
* 'Generate Users' button renamed/re-wired to 'Invite Users'
* Removed logic to display reset password URL
* `config/initializers/devise.rb`: scaffolded config options
* `config/locales/devise_invitable.en.yml`: scaffolded config options
* `20140221002408_devise_invitable_add_to_users.rb`: Migration for devise invitable fields on User model

All tests have been refactored to accommodate these changes.