From 974b5a7b2f31f8e7d6b38a45bfd055a40651c945 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 25 Jul 2014 22:05:23 +0300 Subject: Most starred projects page for Explore area Signed-off-by: Dmitriy Zaporozhets --- app/controllers/explore/projects_controller.rb | 6 ++++++ app/views/explore/projects/_project.html.haml | 7 ++++++- app/views/explore/projects/starred.html.haml | 10 ++++++++++ app/views/layouts/explore.html.haml | 2 ++ config/routes.rb | 1 + 5 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 app/views/explore/projects/starred.html.haml diff --git a/app/controllers/explore/projects_controller.rb b/app/controllers/explore/projects_controller.rb index 05b3289682b..b6fa8b7e387 100644 --- a/app/controllers/explore/projects_controller.rb +++ b/app/controllers/explore/projects_controller.rb @@ -16,4 +16,10 @@ class Explore::ProjectsController < ApplicationController @trending_projects = TrendingProjectsFinder.new.execute(current_user) @trending_projects = @trending_projects.page(params[:page]).per(10) end + + def starred + @starred_projects = ProjectsFinder.new.execute(current_user) + @starred_projects = @starred_projects.order('star_count DESC') + @starred_projects = @starred_projects.page(params[:page]).per(10) + end end diff --git a/app/views/explore/projects/_project.html.haml b/app/views/explore/projects/_project.html.haml index 665d111bead..393c33b266a 100644 --- a/app/views/explore/projects/_project.html.haml +++ b/app/views/explore/projects/_project.html.haml @@ -4,6 +4,10 @@ = visibility_level_icon(project.visibility_level) = link_to project.name_with_namespace, project + - if current_page?(starred_explore_projects_path) + %strong.pull-right + = pluralize project.star_count, 'star' + - if project.description.present? %p.project-description.str-truncated = project.description @@ -17,4 +21,5 @@ = link_to pluralize(project.repository.tag_names.count, 'tag'), project_tags_path(project) - else %i.icon-warning-sign - Empty repository + Empty repository + diff --git a/app/views/explore/projects/starred.html.haml b/app/views/explore/projects/starred.html.haml new file mode 100644 index 00000000000..9c793d4050c --- /dev/null +++ b/app/views/explore/projects/starred.html.haml @@ -0,0 +1,10 @@ +.explore-trending-block + %p.lead + %i.icon-comments-alt + See most starred projects + %hr + .public-projects + %ul.bordered-list + = render @starred_projects + + = paginate @starred_projects, theme: 'gitlab' diff --git a/app/views/layouts/explore.html.haml b/app/views/layouts/explore.html.haml index 73b4940e3d3..d023846c5eb 100644 --- a/app/views/layouts/explore.html.haml +++ b/app/views/layouts/explore.html.haml @@ -20,6 +20,8 @@ %ul.nav.nav-tabs = nav_link(path: 'projects#trending') do = link_to 'Trending Projects', explore_root_path + = nav_link(path: 'projects#starred') do + = link_to 'Most Starred Projects', starred_explore_projects_path = nav_link(path: 'projects#index') do = link_to 'All Projects', explore_projects_path = nav_link(controller: :groups) do diff --git a/config/routes.rb b/config/routes.rb index f8c68eb11a1..3b34ad40297 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -53,6 +53,7 @@ Gitlab::Application.routes.draw do resources :projects, only: [:index] do collection do get :trending + get :starred end end -- cgit v1.2.1 From d3ea53877d689df64db9c68f43e2c08f527b01ed Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 26 Jul 2014 10:33:42 +0300 Subject: Tests for trending/starred pages Signed-off-by: Dmitriy Zaporozhets --- app/views/explore/projects/_project.html.haml | 2 +- features/explore/projects.feature | 14 ++++++++++++++ features/steps/shared/paths.rb | 10 +++++++--- features/steps/shared/project.rb | 5 +++++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/app/views/explore/projects/_project.html.haml b/app/views/explore/projects/_project.html.haml index 393c33b266a..a9498416c8a 100644 --- a/app/views/explore/projects/_project.html.haml +++ b/app/views/explore/projects/_project.html.haml @@ -21,5 +21,5 @@ = link_to pluralize(project.repository.tag_names.count, 'tag'), project_tags_path(project) - else %i.icon-warning-sign - Empty repository + Empty repository diff --git a/features/explore/projects.feature b/features/explore/projects.feature index 2ed9707ec39..9827ebe3e57 100644 --- a/features/explore/projects.feature +++ b/features/explore/projects.feature @@ -100,3 +100,17 @@ Feature: Explore Projects Feature And I visit "Internal" merge requests page And project "Internal" has "Feature implemented" open merge request Then I should see list of merge requests for "Internal" project + + Scenario: Trending page + Given I sign in as a user + And project "Community" has comments + When I visit the explore trending projects + Then I should see project "Community" + And I should not see project "Internal" + And I should not see project "Enterprise" + + Scenario: Most starred page + Given I sign in as a user + When I visit the explore starred projects + Then I should see project "Community" + And I should see project "Internal" diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index 111d40c0e1b..ab1ae31ed74 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -355,9 +355,13 @@ module SharedPaths visit explore_projects_path end - # ---------------------------------------- - # Public Groups - # ---------------------------------------- + step 'I visit the explore trending projects' do + visit trending_explore_projects_path + end + + step 'I visit the explore starred projects' do + visit starred_explore_projects_path + end step 'I visit the public groups area' do visit explore_groups_path diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb index ba6f090a706..1d894b33fbd 100644 --- a/features/steps/shared/project.rb +++ b/features/steps/shared/project.rb @@ -130,4 +130,9 @@ module SharedProject step 'public empty project "Empty Public Project"' do create :empty_project, :public, name: "Empty Public Project" end + + step 'project "Community" has comments' do + project = Project.find_by(name: "Community") + 2.times { create(:note_on_issue, project: project) } + end end -- cgit v1.2.1