This instance was upgraded to Heptapod 0.27.2 on 2021-12-08 at 22:00 UTC+1

Commit 7fd1f6c7 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo
Browse files

Added blank lines to meet style guide

Un-nest title variable output

Update spec test names

Rename sort_value_most_stars -> sort_value_stars_desc

Rename sorted_by_stars -> sorted_by_stars_desc

Renname sort_value_most_stars_asc -> sort_value_stars_asc

Invert feature check, assign feature condition to a variable

Inline conditional nav bar rendering

Invert conditional label

Added follow up task

Fix filters returning 0 projects show the wrong view

Move click action out of test expectation

Use proper variable name for project in before block

Rename projects_sort_admin_options_hash

Renamed projects_sort_admin_options_has to
old_projects_sort_options_hash as its not only used
on the admin screen

Fix extra whitespace errors

Stub project_list_filter_bar in the projects_helper specs

Added follow up task for `show_projects?`

Removed url test expectations
parent fce5de8c0c74
...@@ -239,8 +239,10 @@ def any_projects?(projects) ...@@ -239,8 +239,10 @@ def any_projects?(projects)
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
# TODO: Remove this method when removing the feature flag
# https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/11209#note_162234863
def show_projects?(projects, params) def show_projects?(projects, params)
!!(params[:personal] || params[:name] || any_projects?(projects)) Feature.enabled?(:project_list_filter_bar) || !!(params[:personal] || params[:name] || any_projects?(projects))
end end
def push_to_create_project_command(user = current_user) def push_to_create_project_command(user = current_user)
......
...@@ -128,7 +128,7 @@ def groups_autocomplete(term, limit = 5) ...@@ -128,7 +128,7 @@ def groups_autocomplete(term, limit = 5)
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def projects_autocomplete(term, limit = 5) def projects_autocomplete(term, limit = 5)
current_user.authorized_projects.order_id_desc.search_by_title(term) current_user.authorized_projects.order_id_desc.search_by_title(term)
.sorted_by_stars.non_archived.limit(limit).map do |p| .sorted_by_stars_desc.non_archived.limit(limit).map do |p|
{ {
category: "Projects", category: "Projects",
id: p.id, id: p.id,
......
...@@ -30,17 +30,20 @@ def sort_options_hash ...@@ -30,17 +30,20 @@ def sort_options_hash
end end
def projects_sort_options_hash def projects_sort_options_hash
Feature.enabled?(:project_list_filter_bar) && !current_controller?('admin/projects') ? projects_sort_common_options_hash : projects_sort_admin_options_hash Feature.enabled?(:project_list_filter_bar) && !current_controller?('admin/projects') ? projects_sort_common_options_hash : old_projects_sort_options_hash
end end
def projects_sort_admin_options_hash # TODO: Simplify these sorting options
# https://gitlab.com/gitlab-org/gitlab-ce/issues/60798
# https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/11209#note_162234858
def old_projects_sort_options_hash
options = { options = {
sort_value_latest_activity => sort_title_latest_activity, sort_value_latest_activity => sort_title_latest_activity,
sort_value_name => sort_title_name, sort_value_name => sort_title_name,
sort_value_oldest_activity => sort_title_oldest_activity, sort_value_oldest_activity => sort_title_oldest_activity,
sort_value_oldest_created => sort_title_oldest_created, sort_value_oldest_created => sort_title_oldest_created,
sort_value_recently_created => sort_title_recently_created, sort_value_recently_created => sort_title_recently_created,
sort_value_most_stars => sort_title_most_stars sort_value_stars_desc => sort_title_most_stars
} }
if current_controller?('admin/projects') if current_controller?('admin/projects')
...@@ -55,7 +58,7 @@ def projects_sort_common_options_hash ...@@ -55,7 +58,7 @@ def projects_sort_common_options_hash
sort_value_latest_activity => sort_title_latest_activity, sort_value_latest_activity => sort_title_latest_activity,
sort_value_recently_created => sort_title_created_date, sort_value_recently_created => sort_title_created_date,
sort_value_name => sort_title_name, sort_value_name => sort_title_name,
sort_value_most_stars => sort_title_stars sort_value_stars_desc => sort_title_stars
} }
end end
...@@ -64,11 +67,11 @@ def projects_sort_option_titles ...@@ -64,11 +67,11 @@ def projects_sort_option_titles
sort_value_latest_activity => sort_title_latest_activity, sort_value_latest_activity => sort_title_latest_activity,
sort_value_recently_created => sort_title_created_date, sort_value_recently_created => sort_title_created_date,
sort_value_name => sort_title_name, sort_value_name => sort_title_name,
sort_value_most_stars => sort_title_stars, sort_value_stars_desc => sort_title_stars,
sort_value_oldest_activity => sort_title_latest_activity, sort_value_oldest_activity => sort_title_latest_activity,
sort_value_oldest_created => sort_title_created_date, sort_value_oldest_created => sort_title_created_date,
sort_value_name_desc => sort_title_name, sort_value_name_desc => sort_title_name,
sort_value_most_stars_asc => sort_title_stars sort_value_stars_asc => sort_title_stars
} }
end end
...@@ -77,11 +80,11 @@ def projects_reverse_sort_options_hash ...@@ -77,11 +80,11 @@ def projects_reverse_sort_options_hash
sort_value_latest_activity => sort_value_oldest_activity, sort_value_latest_activity => sort_value_oldest_activity,
sort_value_recently_created => sort_value_oldest_created, sort_value_recently_created => sort_value_oldest_created,
sort_value_name => sort_value_name_desc, sort_value_name => sort_value_name_desc,
sort_value_most_stars => sort_value_most_stars_asc, sort_value_stars_desc => sort_value_stars_asc,
sort_value_oldest_activity => sort_value_latest_activity, sort_value_oldest_activity => sort_value_latest_activity,
sort_value_oldest_created => sort_value_recently_created, sort_value_oldest_created => sort_value_recently_created,
sort_value_name_desc => sort_value_name, sort_value_name_desc => sort_value_name,
sort_value_most_stars_asc => sort_value_most_stars sort_value_stars_asc => sort_value_stars_desc
} }
end end
...@@ -98,7 +101,7 @@ def groups_sort_options_hash ...@@ -98,7 +101,7 @@ def groups_sort_options_hash
def subgroups_sort_options_hash def subgroups_sort_options_hash
groups_sort_options_hash.merge( groups_sort_options_hash.merge(
sort_value_most_stars => sort_title_most_stars sort_value_stars_desc => sort_title_most_stars
) )
end end
...@@ -215,6 +218,8 @@ def issuable_sort_icon_suffix(sort_value) ...@@ -215,6 +218,8 @@ def issuable_sort_icon_suffix(sort_value)
end end
end end
# TODO: dedupicate issuable and project sort direction
# https://gitlab.com/gitlab-org/gitlab-ce/issues/60798
def issuable_sort_direction_button(sort_value) def issuable_sort_direction_button(sort_value)
link_class = 'btn btn-default has-tooltip reverse-sort-btn qa-reverse-sort' link_class = 'btn btn-default has-tooltip reverse-sort-btn qa-reverse-sort'
reverse_sort = issuable_reverse_sort_order_hash[sort_value] reverse_sort = issuable_reverse_sort_order_hash[sort_value]
...@@ -525,11 +530,11 @@ def sort_value_contacted_date ...@@ -525,11 +530,11 @@ def sort_value_contacted_date
'contacted_asc' 'contacted_asc'
end end
def sort_value_most_stars def sort_value_stars_desc
'stars_desc' 'stars_desc'
end end
def sort_value_most_stars_asc def sort_value_stars_asc
'stars_asc' 'stars_asc'
end end
......
...@@ -357,7 +357,7 @@ class Project < ApplicationRecord ...@@ -357,7 +357,7 @@ class Project < ApplicationRecord
# last_activity_at is throttled every minute, but last_repository_updated_at is updated with every push # last_activity_at is throttled every minute, but last_repository_updated_at is updated with every push
scope :sorted_by_activity, -> { reorder("GREATEST(COALESCE(last_activity_at, '1970-01-01'), COALESCE(last_repository_updated_at, '1970-01-01')) DESC") } scope :sorted_by_activity, -> { reorder("GREATEST(COALESCE(last_activity_at, '1970-01-01'), COALESCE(last_repository_updated_at, '1970-01-01')) DESC") }
scope :sorted_by_stars, -> { reorder(star_count: :desc) } scope :sorted_by_stars_desc, -> { reorder(star_count: :desc) }
scope :sorted_by_stars_asc, -> { reorder(star_count: :asc) } scope :sorted_by_stars_asc, -> { reorder(star_count: :asc) }
scope :in_namespace, ->(namespace_ids) { where(namespace_id: namespace_ids) } scope :in_namespace, ->(namespace_ids) { where(namespace_id: namespace_ids) }
...@@ -545,7 +545,7 @@ def sort_by_attribute(method) ...@@ -545,7 +545,7 @@ def sort_by_attribute(method)
when 'latest_activity_asc' when 'latest_activity_asc'
reorder(last_activity_at: :asc) reorder(last_activity_at: :asc)
when 'stars_desc' when 'stars_desc'
sorted_by_stars sorted_by_stars_desc
when 'stars_asc' when 'stars_asc'
sorted_by_stars_asc sorted_by_stars_asc
else else
......
- project_tab_filter = local_assigns.fetch(:project_tab_filter, "") - project_tab_filter = local_assigns.fetch(:project_tab_filter, "")
- feature_project_list_filter_bar = Feature.enabled?(:project_list_filter_bar) - feature_project_list_filter_bar = Feature.enabled?(:project_list_filter_bar)
= content_for :flash_message do = content_for :flash_message do
= render 'shared/project_limit' = render 'shared/project_limit'
......
...@@ -2,14 +2,10 @@ ...@@ -2,14 +2,10 @@
- active_class = 'btn p-2 active' - active_class = 'btn p-2 active'
- project_tab_filter = local_assigns.fetch(:project_tab_filter, "") - project_tab_filter = local_assigns.fetch(:project_tab_filter, "")
- is_explore_trending = project_tab_filter == :explore_trending - is_explore_trending = project_tab_filter == :explore_trending
- feature_project_list_filter_bar = Feature.enabled?(:project_list_filter_bar)
.nav-block{ class: Feature.enabled?(:project_list_filter_bar) ? "w-100" : "" } .nav-block{ class: Feature.enabled?(:project_list_filter_bar) ? "w-100" : "" }
- if !Feature.enabled?(:project_list_filter_bar) - if feature_project_list_filter_bar
%ul.nav-links.mobile-separator.nav.nav-tabs
= nav_link(html_options: { class: ("active" unless params[:personal].present?) }) do
= link_to s_('DashboardProjects|All'), dashboard_projects_path
= nav_link(html_options: { class: ("active" if params[:personal].present?) }) do
= link_to s_('DashboardProjects|Personal'), filter_projects_path(personal: true)
- else
.btn-group.button-filter-group.d-flex.m-0.p-0 .btn-group.button-filter-group.d-flex.m-0.p-0
- if project_tab_filter == :explore || is_explore_trending - if project_tab_filter == :explore || is_explore_trending
= link_to s_('DashboardProjects|Trending'), trending_explore_projects_path, class: is_explore_trending ? active_class : inactive_class = link_to s_('DashboardProjects|Trending'), trending_explore_projects_path, class: is_explore_trending ? active_class : inactive_class
...@@ -17,3 +13,9 @@ ...@@ -17,3 +13,9 @@
- else - else
= link_to s_('DashboardProjects|All'), dashboard_projects_path, class: params[:personal].present? ? inactive_class : active_class = link_to s_('DashboardProjects|All'), dashboard_projects_path, class: params[:personal].present? ? inactive_class : active_class
= link_to s_('DashboardProjects|Personal'), filter_projects_path(personal: true), class: params[:personal].present? ? active_class : inactive_class = link_to s_('DashboardProjects|Personal'), filter_projects_path(personal: true), class: params[:personal].present? ? active_class : inactive_class
- else
%ul.nav-links.mobile-separator.nav.nav-tabs
= nav_link(html_options: { class: ("active" unless params[:personal].present?) }) do
= link_to s_('DashboardProjects|All'), dashboard_projects_path
= nav_link(html_options: { class: ("active" if params[:personal].present?) }) do
= link_to s_('DashboardProjects|Personal'), filter_projects_path(personal: true)
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
= render "projects/last_push" = render "projects/last_push"
- if show_projects?(@projects, params) - if show_projects?(@projects, params)
= render 'dashboard/projects_head' = render 'dashboard/projects_head'
- unless Feature.enabled?(:project_list_filter_bar) = render 'nav' unless Feature.enabled?(:project_list_filter_bar)
= render 'nav'
= render 'projects' = render 'projects'
- else - else
= render "zero_authorized_projects" = render "zero_authorized_projects"
- has_label = local_assigns.fetch(:has_label, false) - has_label = local_assigns.fetch(:has_label, false)
- if current_user - if current_user
.dropdown.js-project-filter-dropdown-wrap .dropdown.js-project-filter-dropdown-wrap
%button.dropdown-menu-toggle{ href: '#', "data-toggle" => "dropdown", 'data-display' => 'static' } %button.dropdown-menu-toggle{ href: '#', "data-toggle" => "dropdown", 'data-display' => 'static' }
- if !has_label - unless has_label
= icon('globe', class: 'mt-1') = icon('globe', class: 'mt-1')
%span.light.ml-3= _("Visibility:") %span.light.ml-3= _("Visibility:")
- if params[:visibility_level].present? - if params[:visibility_level].present?
......
...@@ -15,4 +15,3 @@ ...@@ -15,4 +15,3 @@
= render 'shared/projects/search_form' = render 'shared/projects/search_form'
= render 'shared/projects/dropdown' = render 'shared/projects/dropdown'
= render 'filter' = render 'filter'
- @sort ||= sort_value_latest_activity - @sort ||= sort_value_latest_activity
- project_tab_filter = local_assigns.fetch(:project_tab_filter, "") - project_tab_filter = local_assigns.fetch(:project_tab_filter, "")
.filtered-search-block.row-content-block.bt-0 .filtered-search-block.row-content-block.bt-0
.filtered-search-wrapper.d-flex.flex-nowrap.flex-column.flex-sm-wrap.flex-sm-row.flex-xl-nowrap .filtered-search-wrapper.d-flex.flex-nowrap.flex-column.flex-sm-wrap.flex-sm-row.flex-xl-nowrap
- unless project_tab_filter == :starred - unless project_tab_filter == :starred
......
- @sort ||= sort_value_latest_activity - @sort ||= sort_value_latest_activity
- toggle_text = projects_sort_option_titles[@sort] - toggle_text = projects_sort_option_titles[@sort]
.btn-group.w-100{ role: "group" } .btn-group.w-100{ role: "group" }
.btn-group.w-100.dropdown.js-project-filter-dropdown-wrap{ role: "group" } .btn-group.w-100.dropdown.js-project-filter-dropdown-wrap{ role: "group" }
%button.dropdown-menu-toggle{ id: 'sort-projects-dropdown', type: 'button', data: { toggle: 'dropdown', display: 'static' }, class: 'btn btn-default' } %button.dropdown-menu-toggle{ id: 'sort-projects-dropdown', type: 'button', data: { toggle: 'dropdown', display: 'static' }, class: 'btn btn-default' }
...@@ -10,8 +11,7 @@ ...@@ -10,8 +11,7 @@
= _("Sort by") = _("Sort by")
- projects_sort_options_hash.each do |value, title| - projects_sort_options_hash.each do |value, title|
%li %li
= link_to filter_projects_path(sort: value), class: ("is-active" if toggle_text == title) do = link_to title, filter_projects_path(sort: value), class: ("is-active" if toggle_text == title)
= title
%li.divider %li.divider
%li %li
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
%li %li
= link_to filter_projects_path(archived: 'only'), class: ("is-active" if params[:archived] == 'only') do = link_to filter_projects_path(archived: 'only'), class: ("is-active" if params[:archived] == 'only') do
= _("Show archived projects only") = _("Show archived projects only")
- if current_user && @group && @group.shared_projects.present? - if current_user && @group && @group.shared_projects.present?
%li.divider %li.divider
%li %li
......
...@@ -145,6 +145,7 @@ ...@@ -145,6 +145,7 @@
it 'does not show tabs to filter by all projects or personal' do it 'does not show tabs to filter by all projects or personal' do
visit(starred_dashboard_projects_path) visit(starred_dashboard_projects_path)
expect(page).not_to have_content '.filtered-search-nav' expect(page).not_to have_content '.filtered-search-nav'
end end
end end
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
visit dashboard_projects_path visit dashboard_projects_path
end end
it 'will autocomplete searches', :js do it 'autocompletes searches upon typing', :js do
expect(page).to have_content 'Victorialand' expect(page).to have_content 'Victorialand'
expect(page).to have_content 'Treasure' expect(page).to have_content 'Treasure'
...@@ -85,13 +85,12 @@ def select_dropdown_option(selector, label) ...@@ -85,13 +85,12 @@ def select_dropdown_option(selector, label)
end end
def expect_to_see_projects(sorted_projects) def expect_to_see_projects(sorted_projects)
click_sort_direction
list = page.all('.projects-list .project-name').map(&:text) list = page.all('.projects-list .project-name').map(&:text)
expect(list).to match(sorted_projects) expect(list).to match(sorted_projects)
end end
describe 'Search' do describe 'Search' do
it 'will execute when i click the search button' do it 'executes when the search button is clicked' do
expect(page).to have_content 'Victorialand' expect(page).to have_content 'Victorialand'
expect(page).to have_content 'Treasure' expect(page).to have_content 'Treasure'
...@@ -116,30 +115,37 @@ def expect_to_see_projects(sorted_projects) ...@@ -116,30 +115,37 @@ def expect_to_see_projects(sorted_projects)
describe 'Filter' do describe 'Filter' do
before do before do
priv = create(:project, :private, name: 'Private project', namespace: user.namespace) private_project = create(:project, :private, name: 'Private project', namespace: user.namespace)
int = create(:project, :internal, name: 'Internal project', namespace: user.namespace) internal_project = create(:project, :internal, name: 'Internal project', namespace: user.namespace)
priv.add_maintainer(user) private_project.add_maintainer(user)
int.add_maintainer(user) internal_project.add_maintainer(user)
end end
it 'can filter for only private projects' do it 'filters private projects only' do
select_dropdown_option '#filtered-search-visibility-dropdown', 'Private' select_dropdown_option '#filtered-search-visibility-dropdown', 'Private'
expect(current_url).to match(/visibility_level=0/) expect(current_url).to match(/visibility_level=0/)
list = page.all('.projects-list .project-name').map(&:text) list = page.all('.projects-list .project-name').map(&:text)
expect(list).to match(["Private project", "Treasure", "Victorialand"]) expect(list).to match(["Private project", "Treasure", "Victorialand"])
end end
it 'can filter for only internal projects' do it 'filters internal projects only' do
select_dropdown_option '#filtered-search-visibility-dropdown', 'Internal' select_dropdown_option '#filtered-search-visibility-dropdown', 'Internal'
expect(current_url).to match(/visibility_level=10/) expect(current_url).to match(/visibility_level=10/)
list = page.all('.projects-list .project-name').map(&:text) list = page.all('.projects-list .project-name').map(&:text)
expect(list).to match(['Internal project']) expect(list).to match(['Internal project'])
end end
it 'can filter for any project' do it 'filters any project' do
select_dropdown_option '#filtered-search-visibility-dropdown', 'Any' select_dropdown_option '#filtered-search-visibility-dropdown', 'Any'
list = page.all('.projects-list .project-name').map(&:text) list = page.all('.projects-list .project-name').map(&:text)
expect(list).to match(["Internal project", "Private project", "Treasure", "Victorialand"]) expect(list).to match(["Internal project", "Private project", "Treasure", "Victorialand"])
end end
end end
...@@ -151,8 +157,8 @@ def expect_to_see_projects(sorted_projects) ...@@ -151,8 +157,8 @@ def expect_to_see_projects(sorted_projects)
{ name: 'Cell saga', created_at: Time.now }, { name: 'Cell saga', created_at: Time.now },
{ name: 'Frieza saga', created_at: 10.days.ago } { name: 'Frieza saga', created_at: 10.days.ago }
].each do |item| ].each do |item|
proj = create(:project, name: item[:name], namespace: user.namespace, created_at: item[:created_at]) project = create(:project, name: item[:name], namespace: user.namespace, created_at: item[:created_at])
proj.add_developer(user) project.add_developer(user)
end end
user.toggle_star(project) user.toggle_star(project)
...@@ -160,12 +166,13 @@ def expect_to_see_projects(sorted_projects) ...@@ -160,12 +166,13 @@ def expect_to_see_projects(sorted_projects)
user2.toggle_star(project2) user2.toggle_star(project2)
end end
it 'will include sorting direction' do it 'includes sorting direction' do
sorting_dropdown = page.find('.filtered-search-block #filtered-search-sorting-dropdown') sorting_dropdown = page.find('.filtered-search-block #filtered-search-sorting-dropdown')
expect(sorting_dropdown).to have_css '.reverse-sort-btn' expect(sorting_dropdown).to have_css '.reverse-sort-btn'
end end
it 'will have all sorting options', :js do it 'has all sorting options', :js do
sorting_dropdown = page.find('.filtered-search-block #filtered-search-sorting-dropdown') sorting_dropdown = page.find('.filtered-search-block #filtered-search-sorting-dropdown')
sorting_option_labels = ['Last updated', 'Created date', 'Name', 'Stars'] sorting_option_labels = ['Last updated', 'Created date', 'Name', 'Stars']
...@@ -176,7 +183,7 @@ def expect_to_see_projects(sorted_projects) ...@@ -176,7 +183,7 @@ def expect_to_see_projects(sorted_projects)
end end
end end
it 'will default to Last updated', :js do it 'defaults to "Last updated"', :js do
page.find('.filtered-search-block #filtered-search-sorting-dropdown').click page.find('.filtered-search-block #filtered-search-sorting-dropdown').click
active_sorting_option = page.first('.filtered-search-block #filtered-search-sorting-dropdown .is-active') active_sorting_option = page.first('.filtered-search-block #filtered-search-sorting-dropdown .is-active')
...@@ -184,86 +191,70 @@ def expect_to_see_projects(sorted_projects) ...@@ -184,86 +191,70 @@ def expect_to_see_projects(sorted_projects)
end end
context 'Sorting by name' do context 'Sorting by name' do
it 'will sort the project list' do it 'sorts the project list' do
select_dropdown_option '#filtered-search-sorting-dropdown', 'Name' select_dropdown_option '#filtered-search-sorting-dropdown', 'Name'
desc = ['Victorialand', 'Treasure', 'Red ribbon army', 'Frieza saga', 'Cell saga'] desc = ['Victorialand', 'Treasure', 'Red ribbon army', 'Frieza saga', 'Cell saga']
asc = ['Cell saga', 'Frieza saga', 'Red ribbon army', 'Treasure', 'Victorialand'] asc = ['Cell saga', 'Frieza saga', 'Red ribbon army', 'Treasure', 'Victorialand']
click_sort_direction
expect_to_see_projects(desc) expect_to_see_projects(desc)
expect_to_see_projects(asc)
end
it 'will update the url query' do click_sort_direction
select_dropdown_option '#filtered-search-sorting-dropdown', 'Name'
[/sort=name_desc/, /sort=name_asc/].each do |query_param| expect_to_see_projects(asc)
click_sort_direction
expect(current_url).to match(query_param)
end
end end
end end
context 'Sorting by Last updated' do context 'Sorting by Last updated' do
it 'will sort the project list' do it 'sorts the project list' do
select_dropdown_option '#filtered-search-sorting-dropdown', 'Last updated' select_dropdown_option '#filtered-search-sorting-dropdown', 'Last updated'
desc = ["Frieza saga", "Red ribbon army", "Victorialand", "Treasure", "Cell saga"] desc = ["Frieza saga", "Red ribbon army", "Victorialand", "Treasure", "Cell saga"]
asc = ["Cell saga", "Treasure", "Victorialand", "Red ribbon army", "Frieza saga"] asc = ["Cell saga", "Treasure", "Victorialand", "Red ribbon army", "Frieza saga"]
click_sort_direction
expect_to_see_projects(desc) expect_to_see_projects(desc)
expect_to_see_projects(asc)
end
it 'will update the url query' do click_sort_direction
select_dropdown_option '#filtered-search-sorting-dropdown', 'Last updated'
[/sort=latest_activity_asc/, /sort=latest_activity_desc/].each do |query_param| expect_to_see_projects(asc)
click_sort_direction
expect(current_url).to match(query_param)
end
end end
end end
context 'Sorting by Created date' do context 'Sorting by Created date' do
it 'will sort the project list' do it 'sorts the project list' do
select_dropdown_option '#filtered-search-sorting-dropdown', 'Created date' select_dropdown_option '#filtered-search-sorting-dropdown', 'Created date'
desc = ["Frieza saga", "Red ribbon army", "Victorialand", "Treasure", "Cell saga"] desc = ["Frieza saga", "Red ribbon army", "Victorialand", "Treasure", "Cell saga"]
asc = ["Cell saga", "Treasure", "Victorialand", "Red ribbon army", "Frieza saga"] asc = ["Cell saga", "Treasure", "Victorialand", "Red ribbon army", "Frieza saga"]
click_sort_direction
expect_to_see_projects(desc) expect_to_see_projects(desc)
expect_to_see_projects(asc)
end
it 'will update the url query' do click_sort_direction