Skip to content

Commit

Permalink
Merge pull request #3995 from 3scale/fix-showing-plans-on-service-app…
Browse files Browse the repository at this point in the history
…s-list

Fix a missing Plans column on the applications list
  • Loading branch information
mayorova authored Feb 3, 2025
2 parents 105a326 + 6b718f7 commit bcf3e0b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
6 changes: 3 additions & 3 deletions app/controllers/api/applications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
@application_plans = accessible_plans.where(issuer: @service)
end

def initialize_new_presenter
Expand Down
4 changes: 1 addition & 3 deletions app/views/shared/applications/_listing.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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?
- 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
Expand Down
32 changes: 23 additions & 9 deletions features/api/services/applications/index.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 |
Expand Down Expand Up @@ -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?"
5 changes: 3 additions & 2 deletions features/step_definitions/table_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,7 +40,8 @@

retries ||= 1

expected.diff! table
options = exact_columns.present? ? { surplus_col: true } : {}
expected.diff! table, options
rescue Cucumber::MultilineArgument::DataTable::Different, IndexError => error
if retries > 0
retries -= 1
Expand Down

0 comments on commit bcf3e0b

Please sign in to comment.