-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🦋🥒 updates provider account Invitations index page
- Loading branch information
1 parent
11f3b76
commit 3d3d5af
Showing
17 changed files
with
272 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
app/presenters/provider/admin/account/invitations_index_presenter.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# frozen_string_literal: true | ||
|
||
class Provider::Admin::Account::InvitationsIndexPresenter | ||
include System::UrlHelpers.system_url_helpers | ||
include InvitationsHelper | ||
|
||
alias status invitation_status | ||
alias sent_date invitation_sent_date | ||
|
||
def initialize(invitations, user, params) | ||
@ability = Ability.new(user) | ||
pagination_params = { page: params[:page] || 1, per_page: params[:per_page] || 20 } | ||
sorting_params = "#{params[:sort].presence || 'sent_at'} #{params[:direction].presence || 'desc'}" | ||
@invitations = invitations.paginate(pagination_params) | ||
.reorder(sorting_params) | ||
end | ||
|
||
attr_reader :invitations | ||
|
||
def empty_state? | ||
@invitations.total_entries.zero? | ||
end | ||
|
||
def can_send_invitations? | ||
@ability.can?(:create, Invitation) && @ability.can?(:see, :multiple_users) | ||
end | ||
|
||
# def sent_date(invitation) | ||
# invitation.sent_at&.to_s(:long) || 'Not sent yet' | ||
# end | ||
|
||
# def status(invitation) | ||
# invitation_status(invitation) | ||
# # if invitation.accepted? | ||
# # "yes, on #{invitation.accepted_at.to_s(:short)}" | ||
# # else | ||
# # 'no' | ||
# # end | ||
# end | ||
|
||
def can_manage_invitation?(invitation) | ||
@can_manage_invitation ||= @ability.can?(:manage, invitation) | ||
end | ||
|
||
def toolbar_props | ||
{ | ||
totalEntries: @invitations.total_entries, | ||
actions: [{ | ||
variant: :primary, | ||
label: I18n.t('provider.admin.account.invitations.index.send_invitation_title'), | ||
href: new_provider_admin_account_invitation_path | ||
}] | ||
} | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,16 +9,6 @@ Feature: Invitations | |
And provider "foo.3scale.localhost" has multiple applications enabled | ||
And provider "foo.3scale.localhost" has "multiple_users" switch allowed | ||
|
||
@javascript | ||
Scenario: When switch is denied as provider | ||
Given current domain is the admin domain of provider "foo.3scale.localhost" | ||
And provider "foo.3scale.localhost" has "multiple_users" switch denied | ||
When I log in as provider "foo.3scale.localhost" | ||
And I go to the provider users page | ||
Then I should not see "Invite a New Team Member" | ||
|
||
When I request the url of the provider new invitation page then I should see an exception | ||
|
||
Scenario: When switch is denied as buyer | ||
Given a buyer "apininja" signed up to provider "foo.3scale.localhost" | ||
And provider "foo.3scale.localhost" has "multiple_users" switch denied | ||
|
@@ -37,91 +27,3 @@ Feature: Invitations | |
And I fill in "Send invitation to" with "[email protected]" | ||
And I press "Invite User" | ||
Then invitation from account "apininja" should be sent to "[email protected]" | ||
|
||
@javascript | ||
Scenario: Attempt to send invitation to an email of already existing user | ||
Given an user "alice" of account "foo.3scale.localhost" | ||
And user "alice" has email "[email protected]" | ||
And current domain is the admin domain of provider "foo.3scale.localhost" | ||
When I log in as provider "foo.3scale.localhost" | ||
And I go to the provider new invitation page | ||
And I fill in "Send invitation to" with "[email protected]" | ||
And I press "Send" | ||
Then I should see error "has been taken by another user" for field "Send invitation to" | ||
And no invitation should be sent to "[email protected]" | ||
|
||
@javascript | ||
Scenario: Invitation to an email of already existing pending invitation | ||
Given an invitation from account "foo.3scale.localhost" sent to "[email protected]" | ||
And a clear email queue | ||
And current domain is the admin domain of provider "foo.3scale.localhost" | ||
When I log in as provider "foo.3scale.localhost" | ||
And I go to the provider new invitation page | ||
And I fill in "Send invitation to" with "[email protected]" | ||
And I press "Send" | ||
Then I should see "This invitation has already been sent." | ||
|
||
@javascript | ||
Scenario: Deleted user from invitation with changed email | ||
Given an invitation from account "foo.3scale.localhost" sent to "[email protected]" | ||
When I follow the link to signup provider "foo.3scale.localhost" in the invitation sent to "[email protected]" | ||
And I fill in the invitation signup with email "[email protected]" | ||
When I log in as provider "foo.3scale.localhost" | ||
And I go to the provider users page | ||
Then I should see "[email protected]" | ||
And I should not see "[email protected]" | ||
Then I press "Delete" for user "[email protected]" and confirm the dialog | ||
And I go to the provider sent invitations page | ||
Then I should not see "[email protected]" | ||
|
||
@javascript | ||
Scenario: Accepting an invitation | ||
Given an invitation from account "foo.3scale.localhost" sent to "[email protected]" | ||
And all the rolling updates features are off | ||
And current domain is the admin domain of provider "foo.3scale.localhost" | ||
When I follow the link to signup in the invitation sent to "[email protected]" | ||
And I fill in the invitation signup as "alice" | ||
And current domain is the admin domain of provider "foo.3scale.localhost" | ||
When I try to log in as provider "alice" | ||
Then I should be logged in as "alice" | ||
And follow "API" | ||
And I should see "Analytics" | ||
|
||
@javascript | ||
Scenario: Managing sent invitations | ||
Given the following invitations from account "foo.3scale.localhost" exist: | ||
| Email | State | | ||
| alice@foo.3scale.localhost | pending | | ||
| bob@foo.3scale.localhost | accepted | | ||
And current domain is the admin domain of provider "foo.3scale.localhost" | ||
When I log in as provider "foo.3scale.localhost" | ||
And I go to the provider users page | ||
And I follow "Invitations" | ||
Then I should see "Invitations" in a header | ||
And I should see pending invitation for "[email protected]" | ||
And I should see accepted invitation for "[email protected]" | ||
|
||
@javascript | ||
Scenario: Deleting an invitation | ||
Given an invitation from account "foo.3scale.localhost" sent to "[email protected]" | ||
And current domain is the admin domain of provider "foo.3scale.localhost" | ||
When I log in as provider "foo.3scale.localhost" | ||
And I go to the provider sent invitations page | ||
And I press "Delete" for an invitation from account "foo.3scale.localhost" for "[email protected]" and confirm the dialog | ||
Then I should not see invitation for "[email protected]" | ||
|
||
@javascript | ||
Scenario: Managing sent invitations disabled when multiple_users switch denied | ||
Given provider "foo.3scale.localhost" has "multiple_users" switch denied | ||
And current domain is the admin domain of provider "foo.3scale.localhost" | ||
When I log in as provider "foo.3scale.localhost" | ||
And I go to the provider users page | ||
Then I should not see "Invitations" | ||
|
||
@security @allow-rescue @javascript | ||
Scenario: Only admins can send invitations | ||
Given an active user "alice" of account "foo.3scale.localhost" | ||
And current domain is the admin domain of provider "foo.3scale.localhost" | ||
When I log in as provider "alice" | ||
And I go to the provider new invitation page | ||
Then I should be denied the access |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
@javascript | ||
Feature: Invitations on partner accounts for admins | ||
In order to allow provider account admins to administer their partner accounts | ||
As an admin I want to manage the invitations of users to the partner accounts | ||
Feature: Buyer Account Invitations | ||
|
||
TODO: update as part of THREESCALE-9876 in the same way as features/provider/admin/account/invitations.feature | ||
|
||
Background: | ||
Given the default product of provider "master" has name "Master API" | ||
|
@@ -41,12 +41,14 @@ Feature: Invitations on partner accounts for admins | |
Given an invitation sent to "[email protected]" to join account "lol cats" was accepted | ||
And an invitation sent to "[email protected]" to join account "lol cats" | ||
When I navigate to the page of the invitations of the partner "lol cats" | ||
Then I should see accepted invitation for "[email protected]" | ||
And I should see pending invitation for "[email protected]" | ||
Then the table should contain an accepted invitation from "[email protected]" | ||
And the table should contain a pending invitation from "[email protected]" | ||
|
||
Scenario: Destroying invitations | ||
Given an invitation sent to "[email protected]" to join account "lol cats" | ||
When I navigate to the page of the invitations of the partner "lol cats" | ||
# And select action "Delete" of "[email protected]" | ||
# And confirm the dialog | ||
And I press "Delete" for an invitation from account "lol cats" for "[email protected]" and confirm the dialog | ||
Then I should not see invitation for "[email protected]" | ||
|
||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.