2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2019-12-04 20:38:33 +05:30
require 'spec_helper'
2018-10-15 14:42:47 +05:30
2023-03-04 22:38:38 +05:30
RSpec . describe " User views milestones " , feature_category : :team_planning do
2020-04-08 14:13:33 +05:30
let_it_be ( :user ) { create ( :user ) }
let_it_be ( :project ) { create ( :project ) }
let_it_be ( :milestone ) { create ( :milestone , project : project ) }
2018-10-15 14:42:47 +05:30
before do
project . add_developer ( user )
sign_in ( user )
visit ( project_milestones_path ( project ) )
end
it " shows milestone " do
expect ( page ) . to have_content ( milestone . title )
. and have_content ( milestone . expires_at )
. and have_content ( " Issues " )
2021-04-29 21:17:54 +05:30
. and have_content ( " Merge requests " )
2018-10-15 14:42:47 +05:30
end
2021-01-03 14:25:43 +05:30
context " with issues " , :js do
2020-04-08 14:13:33 +05:30
let_it_be ( :issue ) { create ( :issue , project : project , milestone : milestone ) }
let_it_be ( :closed_issue ) { create ( :closed_issue , project : project , milestone : milestone ) }
2018-10-15 14:42:47 +05:30
it " opens milestone " do
click_link ( milestone . title )
2022-05-07 20:08:51 +05:30
expect ( page ) . to have_current_path ( project_milestone_path ( project , milestone ) , ignore_query : true )
2018-10-15 14:42:47 +05:30
expect ( page ) . to have_content ( milestone . title )
. and have_selector ( " # tab-issues li.issuable-row " , count : 2 )
. and have_content ( issue . title )
. and have_content ( closed_issue . title )
end
end
2019-12-26 22:10:19 +05:30
context " with associated releases " do
2020-04-08 14:13:33 +05:30
let_it_be ( :first_release ) { create ( :release , project : project , name : " The first release " , milestones : [ milestone ] , released_at : Time . zone . parse ( '2019-10-07' ) ) }
2019-12-26 22:10:19 +05:30
context " with a single associated release " do
it " shows the associated release " do
expect ( page ) . to have_content ( " Release #{ first_release . name } " )
expect ( page ) . to have_link ( first_release . name , href : project_releases_path ( project , anchor : first_release . tag ) )
end
end
context " with lots of associated releases " do
2020-04-08 14:13:33 +05:30
let_it_be ( :second_release ) { create ( :release , project : project , name : " The second release " , milestones : [ milestone ] , released_at : first_release . released_at + 1 . day ) }
let_it_be ( :third_release ) { create ( :release , project : project , name : " The third release " , milestones : [ milestone ] , released_at : second_release . released_at + 1 . day ) }
let_it_be ( :fourth_release ) { create ( :release , project : project , name : " The fourth release " , milestones : [ milestone ] , released_at : third_release . released_at + 1 . day ) }
let_it_be ( :fifth_release ) { create ( :release , project : project , name : " The fifth release " , milestones : [ milestone ] , released_at : fourth_release . released_at + 1 . day ) }
2019-12-26 22:10:19 +05:30
it " shows the associated releases and the truncation text " do
expect ( page ) . to have_content ( " Releases #{ fifth_release . name } • #{ fourth_release . name } • #{ third_release . name } • 2 more releases " )
expect ( page ) . to have_link ( fifth_release . name , href : project_releases_path ( project , anchor : fifth_release . tag ) )
expect ( page ) . to have_link ( fourth_release . name , href : project_releases_path ( project , anchor : fourth_release . tag ) )
expect ( page ) . to have_link ( third_release . name , href : project_releases_path ( project , anchor : third_release . tag ) )
expect ( page ) . to have_link ( " 2 more releases " , href : project_releases_path ( project ) )
end
end
end
2018-10-15 14:42:47 +05:30
end
2020-01-01 13:55:28 +05:30
2020-06-23 00:09:42 +05:30
RSpec . describe " User views milestones with no MR " do
2020-04-08 14:13:33 +05:30
let_it_be ( :user ) { create ( :user ) }
let_it_be ( :project ) { create ( :project , :merge_requests_disabled ) }
let_it_be ( :milestone ) { create ( :milestone , project : project ) }
2020-01-01 13:55:28 +05:30
before do
project . add_developer ( user )
sign_in ( user )
visit ( project_milestones_path ( project ) )
end
it " shows milestone " do
expect ( page ) . to have_content ( milestone . title )
. and have_content ( milestone . expires_at )
. and have_content ( " Issues " )
end
it " opens milestone " do
click_link ( milestone . title )
2022-05-07 20:08:51 +05:30
expect ( page ) . to have_current_path ( project_milestone_path ( project , milestone ) , ignore_query : true )
2020-01-01 13:55:28 +05:30
expect ( page ) . to have_content ( milestone . title )
. and have_selector ( " # tab-issues " )
. and have_no_selector ( " # tab-merge-requests " )
end
end