From 9ce56d2b190ac3d3426c66143255f07f758dc6f8 Mon Sep 17 00:00:00 2001 From: Simon Vocella Date: Sun, 1 Jan 2017 15:34:53 +0100 Subject: [PATCH] Add text-warning class in profile settings if the personal_access_token expires soon --- app/views/profiles/personal_access_tokens/index.html.haml | 5 +++-- spec/features/profiles/personal_access_tokens_spec.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/profiles/personal_access_tokens/index.html.haml b/app/views/profiles/personal_access_tokens/index.html.haml index 903b957c26b..e35691d7300 100644 --- a/app/views/profiles/personal_access_tokens/index.html.haml +++ b/app/views/profiles/personal_access_tokens/index.html.haml @@ -51,8 +51,9 @@ %td= token.name %td= token.created_at.to_date.to_s(:medium) %td - - if token.expires_at.present? - = token.expires_at.to_date.to_s(:medium) + - if token.expires? + %span{ class: ('text-warning' if token.expires_soon?) } + In #{distance_of_time_in_words_to_now(token.expires_at)} - else %span.personal-access-tokens-never-expires-label Never %td= token.scopes.present? ? token.scopes.join(", ") : "" diff --git a/spec/features/profiles/personal_access_tokens_spec.rb b/spec/features/profiles/personal_access_tokens_spec.rb index eb7b8a24669..bce4f7c9f3d 100644 --- a/spec/features/profiles/personal_access_tokens_spec.rb +++ b/spec/features/profiles/personal_access_tokens_spec.rb @@ -43,7 +43,7 @@ describe 'Profile > Personal Access Tokens', feature: true, js: true do click_on "Create Personal Access Token" expect(active_personal_access_tokens).to have_text(name) - expect(active_personal_access_tokens).to have_text(Date.today.next_month.at_beginning_of_month.to_s(:medium)) + expect(active_personal_access_tokens).to have_text('In') expect(active_personal_access_tokens).to have_text('api') expect(active_personal_access_tokens).to have_text('read_user') end -- GitLab