-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a missing Plans column on the applications list #3995
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ class Api::ApplicationsController < FrontendController | |
include ApplicationsControllerMethods | ||
|
||
before_action :authorize_partners | ||
before_action :find_plans | ||
before_action :find_service | ||
before_action :find_plans | ||
before_action :find_states, only: :index # rubocop:disable Rails/LexicallyScopedActionFilter | ||
before_action :find_buyer, only: :create | ||
before_action :authorize_multiple_applications, only: :create | ||
|
@@ -42,8 +42,8 @@ def find_service | |
@service = accessible_services.find params[:service_id] | ||
end | ||
|
||
def accessible_plans | ||
super.where(issuer: @service) | ||
def find_plans | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Overriding the But for that purpose I think it is more correct to check all plans (including the custom ones), and not just "stock" plans (non-custom). |
||
@application_plans = accessible_plans.where(issuer: @service) | ||
end | ||
|
||
def initialize_new_presenter | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,7 @@ | |
- content_for :javascripts do | ||
= javascript_packs_with_chunks_tag 'table_toolbar' | ||
|
||
/ FIXME: The first condition does not make any sense but application_plans used to be accessible_plans, now it's accessible_plans.stock | ||
/ FIXME 2: application_plans returns [] in services/:id/applications even though there are plans | ||
- show_application_plans = application_plans.size > 0 && !master_on_premises? | ||
- show_application_plans = application_plans.size > 1 && !master_on_premises? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
- service_column_visible = service.nil? && current_account.multiservice? | ||
div class="pf-c-card" | ||
table class="pf-c-table pf-m-grid-lg" role="grid" aria-label="Applications table" data-toolbar-props=@presenter.toolbar_props.to_json | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,8 @@ Feature: Product > Applications | |
|
||
Background: | ||
Given a provider | ||
And a product "My API" | ||
And another product "Another API" | ||
And a product "My API" with no plans | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to make sure that the plans created below are the only plans on the respective services. |
||
And another product "Another API" with no plans | ||
And the following application plans: | ||
| Product | Name | Cost per month | Setup fee | | ||
| My API | Cheap | 0 | 0 | | ||
|
@@ -42,13 +42,27 @@ Feature: Product > Applications | |
And there should be a link to "Add an application" | ||
|
||
Scenario: Only the current service applications are listed | ||
When they go to product "My API" applications page | ||
Then they should see the following table: | ||
| Name | State | Account | Created on | Traffic on | | ||
| Jane's Full App | live | Jane | December 13, 2023 | | | ||
| Jane's Lite App | live | Jane | December 12, 2023 | | | ||
| Bob's App | live | Bob | December 11, 2023 | | | ||
When they go to product "My API" applications page | ||
Then they should see the following table with exact columns: | ||
| Name | State | Account | Plan | Created on | Traffic on | | ||
| Jane's Full App | live | Jane | Expensive | December 13, 2023 | | | ||
| Jane's Lite App | live | Jane | Cheap | December 12, 2023 | | | ||
| Bob's App | live | Bob | Cheap | December 11, 2023 | | | ||
When they go to product "Another API" applications page | ||
Then they should see the following table: | ||
Then they should see the following table with exact columns: | ||
| Name | State | Account | Created on | Traffic on | | ||
| Another API App | live | Bob | December 10, 2023 | | | ||
|
||
Scenario: Plan column is hidden when the API has a single plan | ||
When they go to product "My API" applications page | ||
Then the table has a column "Plan" | ||
When they go to product "Another API" applications page | ||
Then the table does not have a column "Plan" | ||
|
||
Scenario: Paid? column is shown when finance is enabled | ||
When the provider has "finance" denied | ||
And they go to product "My API" applications page | ||
Then the table does not have a column "Paid?" | ||
When the provider has "finance" allowed | ||
And they go to product "My API" applications page | ||
Then the table has a column "Paid?" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
end | ||
|
||
# TODO: can we use "has_table?" instead of this complex step? | ||
Then "(I )(they )should see (the )following table(:)" do |expected| | ||
Then /^(?:I |they )?should see (?:the )?following table( with exact columns)?:?$/ do |exact_columns, expected| | ||
table = extract_table('table', 'tr:not(.search, .table_title)', 'td:not(.select), th:not(.select)') | ||
|
||
# strip html entities and non letter, space or number characters | ||
|
@@ -40,7 +40,8 @@ | |
|
||
retries ||= 1 | ||
|
||
expected.diff! table | ||
options = exact_columns.present? ? { surplus_col: true } : {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the |
||
expected.diff! table, options | ||
rescue Cucumber::MultilineArgument::DataTable::Different, IndexError => error | ||
if retries > 0 | ||
retries -= 1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This order is important for this controller, as when the plans are searched, they are scoped by the service, so the service needs to be pre-filled.