From 9c7f3fab973ea132c2be406c03cba1771e9933ef Mon Sep 17 00:00:00 2001 From: tauriedavis Date: Mon, 26 Jun 2017 10:53:14 -0700 Subject: 32838 Add wells to admin dashboard overview to fix spacing problems --- app/assets/stylesheets/framework/wells.scss | 14 + app/views/admin/dashboard/index.html.haml | 322 ++++++++++----------- .../unreleased/32838-admin-panel-spacing.yml | 4 + 3 files changed, 179 insertions(+), 161 deletions(-) create mode 100644 changelogs/unreleased/32838-admin-panel-spacing.yml diff --git a/app/assets/stylesheets/framework/wells.scss b/app/assets/stylesheets/framework/wells.scss index 1c1392f8f67..b1ff2659131 100644 --- a/app/assets/stylesheets/framework/wells.scss +++ b/app/assets/stylesheets/framework/wells.scss @@ -3,6 +3,7 @@ color: $gl-text-color; border: 1px solid $border-color; border-radius: $border-radius-default; + margin-bottom: $gl-padding; .well-segment { padding: $gl-padding; @@ -21,6 +22,11 @@ font-size: 12px; } } + + &.admin-well h4 { + border-bottom: 1px solid $border-color; + padding-bottom: 8px; + } } .icon-container { @@ -53,6 +59,14 @@ padding: 15px; } +.dark-well { + background-color: $gray-normal; + + .btn { + width: 100%; + } +} + .well-centered { h1 { font-weight: normal; diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index 3c9f932a225..128b5dc01ab 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -5,182 +5,182 @@ .admin-dashboard.prepend-top-default .row .col-md-4 - %h4 Statistics - %hr - %p - Forks - %span.light.pull-right - = number_with_delimiter(ForkedProjectLink.count) - %p - Issues - %span.light.pull-right - = number_with_delimiter(Issue.count) - %p - Merge Requests - %span.light.pull-right - = number_with_delimiter(MergeRequest.count) - %p - Notes - %span.light.pull-right - = number_with_delimiter(Note.count) - %p - Snippets - %span.light.pull-right - = number_with_delimiter(Snippet.count) - %p - SSH Keys - %span.light.pull-right - = number_with_delimiter(Key.count) - %p - Milestones - %span.light.pull-right - = number_with_delimiter(Milestone.count) - %p - Active Users - %span.light.pull-right - = number_with_delimiter(User.active.count) + .info-well + .well-segment.admin-well + %h4 Statistics + %p + Forks + %span.light.pull-right + = number_with_delimiter(ForkedProjectLink.count) + %p + Issues + %span.light.pull-right + = number_with_delimiter(Issue.count) + %p + Merge Requests + %span.light.pull-right + = number_with_delimiter(MergeRequest.count) + %p + Notes + %span.light.pull-right + = number_with_delimiter(Note.count) + %p + Snippets + %span.light.pull-right + = number_with_delimiter(Snippet.count) + %p + SSH Keys + %span.light.pull-right + = number_with_delimiter(Key.count) + %p + Milestones + %span.light.pull-right + = number_with_delimiter(Milestone.count) + %p + Active Users + %span.light.pull-right + = number_with_delimiter(User.active.count) .col-md-4 - %h4 - Features - %hr - - sign_up = "Sign up" - %p{ "aria-label" => "#{sign_up}: status " + (signup_enabled? ? "on" : "off") } - = sign_up - %span.light.pull-right - = boolean_to_icon signup_enabled? - - ldap = "LDAP" - %p{ "aria-label" => "#{ldap}: status " + (Gitlab.config.ldap.enabled ? "on" : "off") } - = ldap - %span.light.pull-right - = boolean_to_icon Gitlab.config.ldap.enabled - - gravatar = "Gravatar" - %p{ "aria-label" => "#{gravatar}: status " + (gravatar_enabled? ? "on" : "off") } - = gravatar - %span.light.pull-right - = boolean_to_icon gravatar_enabled? - - omniauth = "OmniAuth" - %p{ "aria-label" => "#{omniauth}: status " + (Gitlab.config.omniauth.enabled ? "on" : "off") } - = omniauth - %span.light.pull-right - = boolean_to_icon Gitlab.config.omniauth.enabled - - reply_email = "Reply by email" - %p{ "aria-label" => "#{reply_email}: status " + (Gitlab::IncomingEmail.enabled? ? "on" : "off") } - = reply_email - %span.light.pull-right - = boolean_to_icon Gitlab::IncomingEmail.enabled? - - container_reg = "Container Registry" - %p{ "aria-label" => "#{container_reg}: status " + (Gitlab.config.registry.enabled ? "on" : "off") } - = container_reg - %span.light.pull-right - = boolean_to_icon Gitlab.config.registry.enabled - - gitlab_pages = 'GitLab Pages' - - gitlab_pages_enabled = Gitlab.config.pages.enabled - %p{ "aria-label" => "#{gitlab_pages}: status " + (gitlab_pages_enabled ? "on" : "off") } - = gitlab_pages - %span.light.pull-right - = boolean_to_icon gitlab_pages_enabled - - gitlab_shared_runners = 'Shared Runners' - - gitlab_shared_runners_enabled = Gitlab.config.gitlab_ci.shared_runners_enabled - %p{ "aria-label" => "#{gitlab_shared_runners}: status " + (gitlab_shared_runners_enabled ? "on" : "off") } - = gitlab_shared_runners - %span.light.pull-right - = boolean_to_icon gitlab_shared_runners_enabled - + .info-well + .well-segment.admin-well + %h4 Features + - sign_up = "Sign up" + %p{ "aria-label" => "#{sign_up}: status " + (signup_enabled? ? "on" : "off") } + = sign_up + %span.light.pull-right + = boolean_to_icon signup_enabled? + - ldap = "LDAP" + %p{ "aria-label" => "#{ldap}: status " + (Gitlab.config.ldap.enabled ? "on" : "off") } + = ldap + %span.light.pull-right + = boolean_to_icon Gitlab.config.ldap.enabled + - gravatar = "Gravatar" + %p{ "aria-label" => "#{gravatar}: status " + (gravatar_enabled? ? "on" : "off") } + = gravatar + %span.light.pull-right + = boolean_to_icon gravatar_enabled? + - omniauth = "OmniAuth" + %p{ "aria-label" => "#{omniauth}: status " + (Gitlab.config.omniauth.enabled ? "on" : "off") } + = omniauth + %span.light.pull-right + = boolean_to_icon Gitlab.config.omniauth.enabled + - reply_email = "Reply by email" + %p{ "aria-label" => "#{reply_email}: status " + (Gitlab::IncomingEmail.enabled? ? "on" : "off") } + = reply_email + %span.light.pull-right + = boolean_to_icon Gitlab::IncomingEmail.enabled? + - container_reg = "Container Registry" + %p{ "aria-label" => "#{container_reg}: status " + (Gitlab.config.registry.enabled ? "on" : "off") } + = container_reg + %span.light.pull-right + = boolean_to_icon Gitlab.config.registry.enabled + - gitlab_pages = 'GitLab Pages' + - gitlab_pages_enabled = Gitlab.config.pages.enabled + %p{ "aria-label" => "#{gitlab_pages}: status " + (gitlab_pages_enabled ? "on" : "off") } + = gitlab_pages + %span.light.pull-right + = boolean_to_icon gitlab_pages_enabled + - gitlab_shared_runners = 'Shared Runners' + - gitlab_shared_runners_enabled = Gitlab.config.gitlab_ci.shared_runners_enabled + %p{ "aria-label" => "#{gitlab_shared_runners}: status " + (gitlab_shared_runners_enabled ? "on" : "off") } + = gitlab_shared_runners + %span.light.pull-right + = boolean_to_icon gitlab_shared_runners_enabled .col-md-4 - %h4 - Components - - if current_application_settings.version_check_enabled - .pull-right - = version_status_badge - - %hr - %p - GitLab - %span.pull-right - = Gitlab::VERSION - %p - GitLab Shell - %span.pull-right - = Gitlab::Shell.new.version - %p - GitLab Workhorse - %span.pull-right - = gitlab_workhorse_version - %p - GitLab API - %span.pull-right - = API::API::version - %p - Git - %span.pull-right - = Gitlab::Git.version - %p - Ruby - %span.pull-right - #{RUBY_VERSION}p#{RUBY_PATCHLEVEL} - - %p - Rails - %span.pull-right - #{Rails::VERSION::STRING} - - %p - = Gitlab::Database.adapter_name - %span.pull-right - = Gitlab::Database.version - %hr + .info-well + .well-segment.admin-well + %h4 + Components + - if current_application_settings.version_check_enabled + .pull-right + = version_status_badge + %p + GitLab + %span.pull-right + = Gitlab::VERSION + %p + GitLab Shell + %span.pull-right + = Gitlab::Shell.new.version + %p + GitLab Workhorse + %span.pull-right + = gitlab_workhorse_version + %p + GitLab API + %span.pull-right + = API::API::version + %p + Git + %span.pull-right + = Gitlab::Git.version + %p + Ruby + %span.pull-right + #{RUBY_VERSION}p#{RUBY_PATCHLEVEL} + %p + Rails + %span.pull-right + #{Rails::VERSION::STRING} + %p + = Gitlab::Database.adapter_name + %span.pull-right + = Gitlab::Database.version .row .col-sm-4 - .light-well.well-centered - %h4 Projects - .data + .info-well.dark-well + .well-segment.well-centered = link_to admin_projects_path do - %h1= number_with_delimiter(Project.cached_count) + %h3.text-center + Projects: + = number_with_delimiter(Project.cached_count) %hr = link_to('New project', new_project_path, class: "btn btn-new") .col-sm-4 - .light-well.well-centered - %h4 Users - .data + .info-well.dark-well + .well-segment.well-centered = link_to admin_users_path do - %h1= number_with_delimiter(User.count) + %h3.text-center + Users: + = number_with_delimiter(User.count) %hr = link_to 'New user', new_admin_user_path, class: "btn btn-new" .col-sm-4 - .light-well.well-centered - %h4 Groups - .data + .info-well.dark-well + .well-segment.well-centered = link_to admin_groups_path do - %h1= number_with_delimiter(Group.count) + %h3.text-center + Groups + = number_with_delimiter(Group.count) %hr = link_to 'New group', new_admin_group_path, class: "btn btn-new" - - .row.prepend-top-10 + .row .col-md-4 - %h4 Latest projects - %hr - - @projects.each do |project| - %p - = link_to project.name_with_namespace, [:admin, project.namespace.becomes(Namespace), project], class: 'str-truncated-60' - %span.light.pull-right - #{time_ago_with_tooltip(project.created_at)} - + .info-well + .well-segment.admin-well + %h4 Latest projects + - @projects.each do |project| + %p + = link_to project.name_with_namespace, [:admin, project.namespace.becomes(Namespace), project], class: 'str-truncated-60' + %span.light.pull-right + #{time_ago_with_tooltip(project.created_at)} .col-md-4 - %h4 Latest users - %hr - - @users.each do |user| - %p - = link_to [:admin, user], class: 'str-truncated-60' do - = user.name - %span.light.pull-right - #{time_ago_with_tooltip(user.created_at)} - + .info-well + .well-segment.admin-well + %h4 Latest users + - @users.each do |user| + %p + = link_to [:admin, user], class: 'str-truncated-60' do + = user.name + %span.light.pull-right + #{time_ago_with_tooltip(user.created_at)} .col-md-4 - %h4 Latest groups - %hr - - @groups.each do |group| - %p - = link_to [:admin, group], class: 'str-truncated-60' do - = group.full_name - %span.light.pull-right - #{time_ago_with_tooltip(group.created_at)} + .info-well + .well-segment.admin-well + %h4 Latest groups + - @groups.each do |group| + %p + = link_to [:admin, group], class: 'str-truncated-60' do + = group.full_name + %span.light.pull-right + #{time_ago_with_tooltip(group.created_at)} diff --git a/changelogs/unreleased/32838-admin-panel-spacing.yml b/changelogs/unreleased/32838-admin-panel-spacing.yml new file mode 100644 index 00000000000..ccd703fa43f --- /dev/null +++ b/changelogs/unreleased/32838-admin-panel-spacing.yml @@ -0,0 +1,4 @@ +--- +title: Add wells to admin dashboard overview to fix spacing problems +merge_request: +author: -- cgit v1.2.1 From 9651521ea7f1cd4d77f7ab11359d8b0075b52fa6 Mon Sep 17 00:00:00 2001 From: Alexander Randa Date: Thu, 22 Jun 2017 14:43:52 +0000 Subject: Replace 'snippets/snippets.feature' spinach with rspec --- .../unreleased/23036-replace-snippets-spinach.yml | 4 + features/snippets/snippets.feature | 40 -------- features/steps/shared/paths.rb | 4 - features/steps/shared/snippet.rb | 63 ------------ features/steps/snippets/snippets.rb | 86 ----------------- spec/factories/personal_snippets.rb | 4 - spec/factories/project_snippets.rb | 5 - spec/factories/snippets.rb | 7 ++ spec/features/snippets/create_snippet_spec.rb | 105 -------------------- spec/features/snippets/edit_snippet_spec.rb | 38 -------- .../features/snippets/user_creates_snippet_spec.rb | 107 +++++++++++++++++++++ .../features/snippets/user_deletes_snippet_spec.rb | 19 ++++ spec/features/snippets/user_edits_snippet_spec.rb | 58 +++++++++++ 13 files changed, 195 insertions(+), 345 deletions(-) create mode 100644 changelogs/unreleased/23036-replace-snippets-spinach.yml delete mode 100644 features/snippets/snippets.feature delete mode 100644 features/steps/shared/snippet.rb delete mode 100644 features/steps/snippets/snippets.rb delete mode 100644 spec/factories/personal_snippets.rb delete mode 100644 spec/factories/project_snippets.rb delete mode 100644 spec/features/snippets/create_snippet_spec.rb delete mode 100644 spec/features/snippets/edit_snippet_spec.rb create mode 100644 spec/features/snippets/user_creates_snippet_spec.rb create mode 100644 spec/features/snippets/user_deletes_snippet_spec.rb create mode 100644 spec/features/snippets/user_edits_snippet_spec.rb diff --git a/changelogs/unreleased/23036-replace-snippets-spinach.yml b/changelogs/unreleased/23036-replace-snippets-spinach.yml new file mode 100644 index 00000000000..545805b1302 --- /dev/null +++ b/changelogs/unreleased/23036-replace-snippets-spinach.yml @@ -0,0 +1,4 @@ +--- +title: Replace 'snippets/snippets.feature' spinach with rspec +merge_request: 12385 +author: Alexander Randa @randaalex diff --git a/features/snippets/snippets.feature b/features/snippets/snippets.feature deleted file mode 100644 index 1ad02780229..00000000000 --- a/features/snippets/snippets.feature +++ /dev/null @@ -1,40 +0,0 @@ -@snippets -Feature: Snippets - Background: - Given I sign in as a user - And I have public "Personal snippet one" snippet - And I have private "Personal snippet private" snippet - - @javascript - Scenario: I create new snippet - Given I visit new snippet page - And I submit new snippet "Personal snippet three" - Then I should see snippet "Personal snippet three" - - Scenario: I update "Personal snippet one" - Given I visit snippet page "Personal snippet one" - And I click link "Edit" - And I submit new title "Personal snippet new title" - Then I should see "Personal snippet new title" - - Scenario: Set "Personal snippet one" public - Given I visit snippet page "Personal snippet one" - And I click link "Edit" - And I uncheck "Private" checkbox - Then I should see "Personal snippet one" public - - Scenario: I destroy "Personal snippet one" - Given I visit snippet page "Personal snippet one" - And I click link "Delete" - Then I should not see "Personal snippet one" in snippets - - Scenario: I create new internal snippet - Given I logout directly - And I sign in as an admin - Then I visit new snippet page - And I submit new internal snippet - Then I visit snippet page "Internal personal snippet one" - And I logout directly - Then I sign in as a user - Given I visit new snippet page - Then I visit snippet page "Internal personal snippet one" diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index f0e751b820a..794631a2c4f 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -491,10 +491,6 @@ module SharedPaths visit explore_snippets_path end - step 'I visit new snippet page' do - visit new_snippet_path - end - def root_ref @project.repository.root_ref end diff --git a/features/steps/shared/snippet.rb b/features/steps/shared/snippet.rb deleted file mode 100644 index bb596c1620a..00000000000 --- a/features/steps/shared/snippet.rb +++ /dev/null @@ -1,63 +0,0 @@ -module SharedSnippet - include Spinach::DSL - - step 'I have public "Personal snippet one" snippet' do - create(:personal_snippet, - title: "Personal snippet one", - content: "Test content", - file_name: "snippet.rb", - visibility_level: Snippet::PUBLIC, - author: current_user) - end - - step 'I have private "Personal snippet private" snippet' do - create(:personal_snippet, - title: "Personal snippet private", - content: "Provate content", - file_name: "private_snippet.rb", - visibility_level: Snippet::PRIVATE, - author: current_user) - end - - step 'I have internal "Personal snippet internal" snippet' do - create(:personal_snippet, - title: "Personal snippet internal", - content: "Provate content", - file_name: "internal_snippet.rb", - visibility_level: Snippet::INTERNAL, - author: current_user) - end - - step 'I have a public many lined snippet' do - create(:personal_snippet, - title: 'Many lined snippet', - content: <<-END.gsub(/^\s+\|/, ''), - |line one - |line two - |line three - |line four - |line five - |line six - |line seven - |line eight - |line nine - |line ten - |line eleven - |line twelve - |line thirteen - |line fourteen - END - file_name: 'many_lined_snippet.rb', - visibility_level: Snippet::PUBLIC, - author: current_user) - end - - step 'There is public "Personal snippet one" snippet' do - create(:personal_snippet, - title: "Personal snippet one", - content: "Test content", - file_name: "snippet.rb", - visibility_level: Snippet::PUBLIC, - author: create(:user)) - end -end diff --git a/features/steps/snippets/snippets.rb b/features/steps/snippets/snippets.rb deleted file mode 100644 index a4fc77746ee..00000000000 --- a/features/steps/snippets/snippets.rb +++ /dev/null @@ -1,86 +0,0 @@ -class Spinach::Features::Snippets < Spinach::FeatureSteps - include SharedAuthentication - include SharedPaths - include SharedProject - include SharedSnippet - include WaitForRequests - - step 'I click link "Personal snippet one"' do - click_link "Personal snippet one" - end - - step 'I should not see "Personal snippet one" in snippets' do - expect(page).not_to have_content "Personal snippet one" - end - - step 'I click link "Edit"' do - page.within ".detail-page-header" do - first(:link, "Edit").click - end - end - - step 'I click link "Delete"' do - first(:link, "Delete").click - end - - step 'I submit new snippet "Personal snippet three"' do - fill_in "personal_snippet_title", with: "Personal snippet three" - fill_in "personal_snippet_file_name", with: "my_snippet.rb" - page.within('.file-editor') do - find('.ace_editor').native.send_keys 'Content of snippet three' - end - click_button "Create snippet" - wait_for_requests - end - - step 'I submit new internal snippet' do - fill_in "personal_snippet_title", with: "Internal personal snippet one" - fill_in "personal_snippet_file_name", with: "my_snippet.rb" - choose 'personal_snippet_visibility_level_10' - - page.within('.file-editor') do - find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of internal snippet' - end - - click_button "Create snippet" - end - - step 'I should see snippet "Personal snippet three"' do - expect(page).to have_content "Personal snippet three" - expect(page).to have_content "Content of snippet three" - end - - step 'I submit new title "Personal snippet new title"' do - fill_in "personal_snippet_title", with: "Personal snippet new title" - click_button "Save" - end - - step 'I should see "Personal snippet new title"' do - expect(page).to have_content "Personal snippet new title" - end - - step 'I uncheck "Private" checkbox' do - choose "Internal" - click_button "Save" - end - - step 'I should see "Personal snippet one" public' do - expect(page).to have_no_xpath("//i[@class='public-snippet']") - end - - step 'I visit snippet page "Personal snippet one"' do - visit snippet_path(snippet) - end - - step 'I visit snippet page "Internal personal snippet one"' do - visit snippet_path(internal_snippet) - end - - def snippet - @snippet ||= PersonalSnippet.find_by!(title: "Personal snippet one") - end - - def internal_snippet - @snippet ||= PersonalSnippet.find_by!(title: "Internal personal snippet one") - end -end diff --git a/spec/factories/personal_snippets.rb b/spec/factories/personal_snippets.rb deleted file mode 100644 index 0f13b2c1020..00000000000 --- a/spec/factories/personal_snippets.rb +++ /dev/null @@ -1,4 +0,0 @@ -FactoryGirl.define do - factory :personal_snippet, parent: :snippet, class: :PersonalSnippet do - end -end diff --git a/spec/factories/project_snippets.rb b/spec/factories/project_snippets.rb deleted file mode 100644 index e0fe1b36fd3..00000000000 --- a/spec/factories/project_snippets.rb +++ /dev/null @@ -1,5 +0,0 @@ -FactoryGirl.define do - factory :project_snippet, parent: :snippet, class: :ProjectSnippet do - project factory: :empty_project - end -end diff --git a/spec/factories/snippets.rb b/spec/factories/snippets.rb index 388f662e6e5..f6ce99d50f9 100644 --- a/spec/factories/snippets.rb +++ b/spec/factories/snippets.rb @@ -18,4 +18,11 @@ FactoryGirl.define do visibility_level Snippet::PRIVATE end end + + factory :project_snippet, parent: :snippet, class: :ProjectSnippet do + project factory: :empty_project + end + + factory :personal_snippet, parent: :snippet, class: :PersonalSnippet do + end end diff --git a/spec/features/snippets/create_snippet_spec.rb b/spec/features/snippets/create_snippet_spec.rb deleted file mode 100644 index ac5c14ed427..00000000000 --- a/spec/features/snippets/create_snippet_spec.rb +++ /dev/null @@ -1,105 +0,0 @@ -require 'rails_helper' - -feature 'Create Snippet', :js, feature: true do - include DropzoneHelper - - before do - gitlab_sign_in :user - visit new_snippet_path - end - - def fill_form - fill_in 'personal_snippet_title', with: 'My Snippet Title' - fill_in 'personal_snippet_description', with: 'My Snippet **Description**' - page.within('.file-editor') do - find('.ace_editor').native.send_keys 'Hello World!' - end - end - - scenario 'Authenticated user creates a snippet' do - fill_form - - click_button('Create snippet') - wait_for_requests - - expect(page).to have_content('My Snippet Title') - page.within('.snippet-header .description') do - expect(page).to have_content('My Snippet Description') - expect(page).to have_selector('strong') - end - expect(page).to have_content('Hello World!') - end - - scenario 'previews a snippet with file' do - fill_in 'personal_snippet_description', with: 'My Snippet' - dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') - find('.js-md-preview-button').click - - page.within('#new_personal_snippet .md-preview') do - expect(page).to have_content('My Snippet') - - link = find('a.no-attachment-icon img[alt="banana_sample"]')['src'] - expect(link).to match(%r{/uploads/temp/\h{32}/banana_sample\.gif\z}) - - visit(link) - expect(page.status_code).to eq(200) - end - end - - scenario 'uploads a file when dragging into textarea' do - fill_form - - dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') - - expect(page.find_field("personal_snippet_description").value).to have_content('banana_sample') - - click_button('Create snippet') - wait_for_requests - - link = find('a.no-attachment-icon img[alt="banana_sample"]')['src'] - expect(link).to match(%r{/uploads/personal_snippet/#{Snippet.last.id}/\h{32}/banana_sample\.gif\z}) - - visit(link) - expect(page.status_code).to eq(200) - end - - scenario 'validation fails for the first time' do - fill_in 'personal_snippet_title', with: 'My Snippet Title' - click_button('Create snippet') - - expect(page).to have_selector('#error_explanation') - - fill_form - dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') - - click_button('Create snippet') - wait_for_requests - - expect(page).to have_content('My Snippet Title') - page.within('.snippet-header .description') do - expect(page).to have_content('My Snippet Description') - expect(page).to have_selector('strong') - end - expect(page).to have_content('Hello World!') - link = find('a.no-attachment-icon img[alt="banana_sample"]')['src'] - expect(link).to match(%r{/uploads/personal_snippet/#{Snippet.last.id}/\h{32}/banana_sample\.gif\z}) - - visit(link) - expect(page.status_code).to eq(200) - end - - scenario 'Authenticated user creates a snippet with + in filename' do - fill_in 'personal_snippet_title', with: 'My Snippet Title' - page.within('.file-editor') do - find(:xpath, "//input[@id='personal_snippet_file_name']").set 'snippet+file+name' - find('.ace_editor').native.send_keys 'Hello World!' - end - - click_button 'Create snippet' - wait_for_requests - - expect(page).to have_content('My Snippet Title') - expect(page).to have_content('snippet+file+name') - expect(page).to have_content('Hello World!') - end -end diff --git a/spec/features/snippets/edit_snippet_spec.rb b/spec/features/snippets/edit_snippet_spec.rb deleted file mode 100644 index 860e1b156d6..00000000000 --- a/spec/features/snippets/edit_snippet_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'rails_helper' - -feature 'Edit Snippet', :js, feature: true do - include DropzoneHelper - - let(:file_name) { 'test.rb' } - let(:content) { 'puts "test"' } - - let(:user) { create(:user) } - let(:snippet) { create(:personal_snippet, :public, file_name: file_name, content: content, author: user) } - - before do - gitlab_sign_in(user) - - visit edit_snippet_path(snippet) - wait_for_requests - end - - it 'updates the snippet' do - fill_in 'personal_snippet_title', with: 'New Snippet Title' - - click_button('Save changes') - wait_for_requests - - expect(page).to have_content('New Snippet Title') - end - - it 'updates the snippet with files attached' do - dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') - expect(page.find_field("personal_snippet_description").value).to have_content('banana_sample') - - click_button('Save changes') - wait_for_requests - - link = find('a.no-attachment-icon img[alt="banana_sample"]')['src'] - expect(link).to match(%r{/uploads/personal_snippet/#{snippet.id}/\h{32}/banana_sample\.gif\z}) - end -end diff --git a/spec/features/snippets/user_creates_snippet_spec.rb b/spec/features/snippets/user_creates_snippet_spec.rb new file mode 100644 index 00000000000..57dec14b480 --- /dev/null +++ b/spec/features/snippets/user_creates_snippet_spec.rb @@ -0,0 +1,107 @@ +require 'rails_helper' + +feature 'User creates snippet', :js, feature: true do + include DropzoneHelper + + let(:user) { create(:user) } + + before do + sign_in(user) + visit new_snippet_path + end + + def fill_form + fill_in 'personal_snippet_title', with: 'My Snippet Title' + fill_in 'personal_snippet_description', with: 'My Snippet **Description**' + page.within('.file-editor') do + find('.ace_editor').native.send_keys 'Hello World!' + end + end + + scenario 'Authenticated user creates a snippet' do + fill_form + + click_button('Create snippet') + wait_for_requests + + expect(page).to have_content('My Snippet Title') + page.within('.snippet-header .description') do + expect(page).to have_content('My Snippet Description') + expect(page).to have_selector('strong') + end + expect(page).to have_content('Hello World!') + end + + scenario 'previews a snippet with file' do + fill_in 'personal_snippet_description', with: 'My Snippet' + dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') + find('.js-md-preview-button').click + + page.within('#new_personal_snippet .md-preview') do + expect(page).to have_content('My Snippet') + + link = find('a.no-attachment-icon img[alt="banana_sample"]')['src'] + expect(link).to match(%r{/uploads/temp/\h{32}/banana_sample\.gif\z}) + + visit(link) + expect(page.status_code).to eq(200) + end + end + + scenario 'uploads a file when dragging into textarea' do + fill_form + + dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') + + expect(page.find_field("personal_snippet_description").value).to have_content('banana_sample') + + click_button('Create snippet') + wait_for_requests + + link = find('a.no-attachment-icon img[alt="banana_sample"]')['src'] + expect(link).to match(%r{/uploads/personal_snippet/#{Snippet.last.id}/\h{32}/banana_sample\.gif\z}) + + visit(link) + expect(page.status_code).to eq(200) + end + + scenario 'validation fails for the first time' do + fill_in 'personal_snippet_title', with: 'My Snippet Title' + click_button('Create snippet') + + expect(page).to have_selector('#error_explanation') + + fill_form + dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') + + click_button('Create snippet') + wait_for_requests + + expect(page).to have_content('My Snippet Title') + page.within('.snippet-header .description') do + expect(page).to have_content('My Snippet Description') + expect(page).to have_selector('strong') + end + expect(page).to have_content('Hello World!') + link = find('a.no-attachment-icon img[alt="banana_sample"]')['src'] + expect(link).to match(%r{/uploads/personal_snippet/#{Snippet.last.id}/\h{32}/banana_sample\.gif\z}) + + visit(link) + expect(page.status_code).to eq(200) + end + + scenario 'Authenticated user creates a snippet with + in filename' do + fill_in 'personal_snippet_title', with: 'My Snippet Title' + page.within('.file-editor') do + find(:xpath, "//input[@id='personal_snippet_file_name']").set 'snippet+file+name' + find('.ace_editor').native.send_keys 'Hello World!' + end + + click_button 'Create snippet' + wait_for_requests + + expect(page).to have_content('My Snippet Title') + expect(page).to have_content('snippet+file+name') + expect(page).to have_content('Hello World!') + end +end diff --git a/spec/features/snippets/user_deletes_snippet_spec.rb b/spec/features/snippets/user_deletes_snippet_spec.rb new file mode 100644 index 00000000000..162c2c9e730 --- /dev/null +++ b/spec/features/snippets/user_deletes_snippet_spec.rb @@ -0,0 +1,19 @@ +require 'rails_helper' + +feature 'User deletes snippet', feature: true do + let(:user) { create(:user) } + let(:content) { 'puts "test"' } + let(:snippet) { create(:personal_snippet, :public, content: content, author: user) } + + before do + sign_in(user) + + visit snippet_path(snippet) + end + + it 'deletes the snippet' do + first(:link, 'Delete').click + + expect(page).not_to have_content(snippet.title) + end +end diff --git a/spec/features/snippets/user_edits_snippet_spec.rb b/spec/features/snippets/user_edits_snippet_spec.rb new file mode 100644 index 00000000000..cff64423873 --- /dev/null +++ b/spec/features/snippets/user_edits_snippet_spec.rb @@ -0,0 +1,58 @@ +require 'rails_helper' + +feature 'User edits snippet', :js, feature: true do + include DropzoneHelper + + let(:file_name) { 'test.rb' } + let(:content) { 'puts "test"' } + + let(:user) { create(:user) } + let(:snippet) { create(:personal_snippet, :public, file_name: file_name, content: content, author: user) } + + before do + sign_in(user) + + visit edit_snippet_path(snippet) + wait_for_requests + end + + it 'updates the snippet' do + fill_in 'personal_snippet_title', with: 'New Snippet Title' + + click_button('Save changes') + wait_for_requests + + expect(page).to have_content('New Snippet Title') + end + + it 'updates the snippet with files attached' do + dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') + expect(page.find_field('personal_snippet_description').value).to have_content('banana_sample') + + click_button('Save changes') + wait_for_requests + + link = find('a.no-attachment-icon img[alt="banana_sample"]')['src'] + expect(link).to match(%r{/uploads/personal_snippet/#{snippet.id}/\h{32}/banana_sample\.gif\z}) + end + + it 'updates the snippet to make it internal' do + choose 'Internal' + + click_button 'Save changes' + wait_for_requests + + expect(page).to have_no_xpath("//i[@class='fa fa-lock']") + expect(page).to have_xpath("//i[@class='fa fa-shield']") + end + + it 'updates the snippet to make it public' do + choose 'Public' + + click_button 'Save changes' + wait_for_requests + + expect(page).to have_no_xpath("//i[@class='fa fa-lock']") + expect(page).to have_xpath("//i[@class='fa fa-globe']") + end +end -- cgit v1.2.1 From 1f1fba553a54fe69b3b9308a187433fc5a51ee20 Mon Sep 17 00:00:00 2001 From: Simon Knox Date: Wed, 5 Jul 2017 19:08:30 +1000 Subject: fix sidebar padding for full-width items (Time Tracking help) --- app/assets/stylesheets/framework/sidebar.scss | 2 +- app/assets/stylesheets/pages/issuable.scss | 5 ++++- changelogs/unreleased/34578-sidebar-padding.yml | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/34578-sidebar-padding.yml diff --git a/app/assets/stylesheets/framework/sidebar.scss b/app/assets/stylesheets/framework/sidebar.scss index 5cf9330b8f8..542b641e3dd 100644 --- a/app/assets/stylesheets/framework/sidebar.scss +++ b/app/assets/stylesheets/framework/sidebar.scss @@ -92,7 +92,7 @@ @mixin maintain-sidebar-dimensions { display: block; width: $gutter-width; - padding: 10px 20px; + padding: 10px 0; } .issues-bulk-update.right-sidebar { diff --git a/app/assets/stylesheets/pages/issuable.scss b/app/assets/stylesheets/pages/issuable.scss index 057d457b3a2..47f50083726 100644 --- a/app/assets/stylesheets/pages/issuable.scss +++ b/app/assets/stylesheets/pages/issuable.scss @@ -200,7 +200,6 @@ right: 0; transition: width .3s; background: $gray-light; - padding: 0 20px; z-index: 200; overflow: hidden; @@ -224,6 +223,10 @@ } } + .issuable-sidebar { + padding: 0 20px; + } + .issuable-sidebar-header { padding-top: 10px; } diff --git a/changelogs/unreleased/34578-sidebar-padding.yml b/changelogs/unreleased/34578-sidebar-padding.yml new file mode 100644 index 00000000000..dc4647298e6 --- /dev/null +++ b/changelogs/unreleased/34578-sidebar-padding.yml @@ -0,0 +1,4 @@ +--- +title: fix left & right padding on sidebar +merge_request: +author: -- cgit v1.2.1 From 416c67541f1bafb129fdaed33dc2d94e2c21a718 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Wed, 5 Jul 2017 07:42:17 -0700 Subject: Disable Flipper memoizer in tests to avoid transient failures Closes #34278 --- config/initializers/flipper.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/initializers/flipper.rb b/config/initializers/flipper.rb index 0fee832788d..8ec9613a4b7 100644 --- a/config/initializers/flipper.rb +++ b/config/initializers/flipper.rb @@ -1,4 +1,6 @@ require 'flipper/middleware/memoizer' -Rails.application.config.middleware.use Flipper::Middleware::Memoizer, - lambda { Feature.flipper } +unless Rails.env.test? + Rails.application.config.middleware.use Flipper::Middleware::Memoizer, + lambda { Feature.flipper } +end -- cgit v1.2.1 From 8a3022a69826272fb5eb111c016770965a5484b3 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Wed, 5 Jul 2017 16:01:40 +0000 Subject: Revert "Merge branch '18000-remember-me-for-oauth-login' into 'master'" This reverts merge request !11963 --- app/assets/javascripts/dispatcher.js | 2 - app/assets/javascripts/oauth_remember_me.js | 32 ------ app/controllers/omniauth_callbacks_controller.rb | 8 -- app/views/devise/shared/_omniauth_box.html.haml | 5 +- .../18000-remember-me-for-oauth-login.yml | 4 - config/gitlab.yml.example | 47 --------- lib/tasks/gitlab/info.rake | 3 +- spec/features/oauth_login_spec.rb | 112 --------------------- .../fixtures/oauth_remember_me.html.haml | 5 - spec/javascripts/oauth_remember_me_spec.js | 26 ----- spec/support/capybara_helpers.rb | 5 - spec/support/login_helpers.rb | 13 +-- 12 files changed, 4 insertions(+), 258 deletions(-) delete mode 100644 app/assets/javascripts/oauth_remember_me.js delete mode 100644 changelogs/unreleased/18000-remember-me-for-oauth-login.yml delete mode 100644 spec/features/oauth_login_spec.rb delete mode 100644 spec/javascripts/fixtures/oauth_remember_me.html.haml delete mode 100644 spec/javascripts/oauth_remember_me_spec.js diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index e924fde60bf..4247540de22 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -56,7 +56,6 @@ import GfmAutoComplete from './gfm_auto_complete'; import ShortcutsBlob from './shortcuts_blob'; import initSettingsPanels from './settings_panels'; import initExperimentalFlags from './experimental_flags'; -import OAuthRememberMe from './oauth_remember_me'; (function() { var Dispatcher; @@ -128,7 +127,6 @@ import OAuthRememberMe from './oauth_remember_me'; case 'sessions:new': new UsernameValidator(); new ActiveTabMemoizer(); - new OAuthRememberMe({ container: $(".omniauth-container") }).bindEvents(); break; case 'projects:boards:show': case 'projects:boards:index': diff --git a/app/assets/javascripts/oauth_remember_me.js b/app/assets/javascripts/oauth_remember_me.js deleted file mode 100644 index ffc2dd6bbca..00000000000 --- a/app/assets/javascripts/oauth_remember_me.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * OAuth-based login buttons have a separate "remember me" checkbox. - * - * Toggling this checkbox adds/removes a `remember_me` parameter to the - * login buttons' href, which is passed on to the omniauth callback. - **/ - -export default class OAuthRememberMe { - constructor(opts = {}) { - this.container = opts.container || ''; - this.loginLinkSelector = '.oauth-login'; - } - - bindEvents() { - $('#remember_me', this.container).on('click', this.toggleRememberMe); - } - - // eslint-disable-next-line class-methods-use-this - toggleRememberMe(event) { - const rememberMe = $(event.target).is(':checked'); - - $('.oauth-login', this.container).each((i, element) => { - const href = $(element).attr('href'); - - if (rememberMe) { - $(element).attr('href', `${href}?remember_me=1`); - } else { - $(element).attr('href', href.replace('?remember_me=1', '')); - } - }); - } -} diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index 323d5d26eb6..b82681b197e 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -1,6 +1,5 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController include AuthenticatesWithTwoFactor - include Devise::Controllers::Rememberable protect_from_forgery except: [:kerberos, :saml, :cas3] @@ -116,10 +115,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController if @user.persisted? && @user.valid? log_audit_event(@user, with: oauth['provider']) if @user.two_factor_enabled? - params[:remember_me] = '1' if remember_me? prompt_for_two_factor(@user) else - remember_me(@user) if remember_me? sign_in_and_redirect(@user) end else @@ -150,9 +147,4 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController AuditEventService.new(user, user, options) .for_authentication.security_event end - - def remember_me? - request_params = request.env['omniauth.params'] - (request_params['remember_me'] == '1') if request_params.present? - end end diff --git a/app/views/devise/shared/_omniauth_box.html.haml b/app/views/devise/shared/_omniauth_box.html.haml index e80d10dc8f1..f92f89e73ff 100644 --- a/app/views/devise/shared/_omniauth_box.html.haml +++ b/app/views/devise/shared/_omniauth_box.html.haml @@ -6,7 +6,4 @@ - providers.each do |provider| %span.light - has_icon = provider_has_icon?(provider) - = link_to provider_image_tag(provider), omniauth_authorize_path(:user, provider), method: :post, class: 'oauth-login' + (has_icon ? ' oauth-image-link' : ' btn'), id: "oauth-login-#{provider}" - %fieldset - = check_box_tag :remember_me - = label_tag :remember_me, 'Remember Me' + = link_to provider_image_tag(provider), omniauth_authorize_path(:user, provider), method: :post, class: (has_icon ? 'oauth-image-link' : 'btn') diff --git a/changelogs/unreleased/18000-remember-me-for-oauth-login.yml b/changelogs/unreleased/18000-remember-me-for-oauth-login.yml deleted file mode 100644 index 1ef92756a76..00000000000 --- a/changelogs/unreleased/18000-remember-me-for-oauth-login.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Honor the "Remember me" parameter for OAuth-based login -merge_request: 11963 -author: diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index fdc2b24e110..4b81fd90f59 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -619,53 +619,6 @@ test: title: "JIRA" url: https://sample_company.atlassian.net project_key: PROJECT - - omniauth: - enabled: true - allow_single_sign_on: true - external_providers: [] - - providers: - - { name: 'cas3', - label: 'cas3', - args: { url: 'https://sso.example.com', - disable_ssl_verification: false, - login_url: '/cas/login', - service_validate_url: '/cas/p3/serviceValidate', - logout_url: '/cas/logout'} } - - { name: 'authentiq', - app_id: 'YOUR_CLIENT_ID', - app_secret: 'YOUR_CLIENT_SECRET', - args: { scope: 'aq:name email~rs address aq:push' } } - - { name: 'github', - app_id: 'YOUR_APP_ID', - app_secret: 'YOUR_APP_SECRET', - url: "https://github.com/", - verify_ssl: false, - args: { scope: 'user:email' } } - - { name: 'bitbucket', - app_id: 'YOUR_APP_ID', - app_secret: 'YOUR_APP_SECRET' } - - { name: 'gitlab', - app_id: 'YOUR_APP_ID', - app_secret: 'YOUR_APP_SECRET', - args: { scope: 'api' } } - - { name: 'google_oauth2', - app_id: 'YOUR_APP_ID', - app_secret: 'YOUR_APP_SECRET', - args: { access_type: 'offline', approval_prompt: '' } } - - { name: 'facebook', - app_id: 'YOUR_APP_ID', - app_secret: 'YOUR_APP_SECRET' } - - { name: 'twitter', - app_id: 'YOUR_APP_ID', - app_secret: 'YOUR_APP_SECRET' } - - { name: 'auth0', - args: { - client_id: 'YOUR_AUTH0_CLIENT_ID', - client_secret: 'YOUR_AUTH0_CLIENT_SECRET', - namespace: 'YOUR_AUTH0_DOMAIN' } } - ldap: enabled: false servers: diff --git a/lib/tasks/gitlab/info.rake b/lib/tasks/gitlab/info.rake index e9fb6a008b0..e3883278886 100644 --- a/lib/tasks/gitlab/info.rake +++ b/lib/tasks/gitlab/info.rake @@ -42,7 +42,8 @@ namespace :gitlab do http_clone_url = project.http_url_to_repo ssh_clone_url = project.ssh_url_to_repo - omniauth_providers = Gitlab.config.omniauth.providers.map { |provider| provider['name'] } + omniauth_providers = Gitlab.config.omniauth.providers + omniauth_providers.map! { |provider| provider['name'] } puts "" puts "GitLab information".color(:yellow) diff --git a/spec/features/oauth_login_spec.rb b/spec/features/oauth_login_spec.rb deleted file mode 100644 index 452b920307c..00000000000 --- a/spec/features/oauth_login_spec.rb +++ /dev/null @@ -1,112 +0,0 @@ -require 'spec_helper' - -feature 'OAuth Login', js: true do - def enter_code(code) - fill_in 'user_otp_attempt', with: code - click_button 'Verify code' - end - - def stub_omniauth_config(provider) - OmniAuth.config.add_mock(provider, OmniAuth::AuthHash.new(provider: provider.to_s, uid: "12345")) - Rails.application.env_config['devise.mapping'] = Devise.mappings[:user] - Rails.application.env_config['omniauth.auth'] = OmniAuth.config.mock_auth[provider] - end - - providers = [:github, :twitter, :bitbucket, :gitlab, :google_oauth2, - :facebook, :authentiq, :cas3, :auth0] - - before(:all) do - # The OmniAuth `full_host` parameter doesn't get set correctly (it gets set to something like `http://localhost` - # here), and causes integration tests to fail with 404s. We set the `full_host` by removing the request path (and - # anything after it) from the request URI. - @omniauth_config_full_host = OmniAuth.config.full_host - OmniAuth.config.full_host = ->(request) { request['REQUEST_URI'].sub(/#{request['REQUEST_PATH']}.*/, '') } - end - - after(:all) do - OmniAuth.config.full_host = @omniauth_config_full_host - end - - providers.each do |provider| - context "when the user logs in using the #{provider} provider" do - context 'when two-factor authentication is disabled' do - it 'logs the user in' do - stub_omniauth_config(provider) - user = create(:omniauth_user, extern_uid: 'my-uid', provider: provider.to_s) - login_via(provider.to_s, user, 'my-uid') - - expect(current_path).to eq root_path - end - end - - context 'when two-factor authentication is enabled' do - it 'logs the user in' do - stub_omniauth_config(provider) - user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: provider.to_s) - login_via(provider.to_s, user, 'my-uid') - - enter_code(user.current_otp) - expect(current_path).to eq root_path - end - end - - context 'when "remember me" is checked' do - context 'when two-factor authentication is disabled' do - it 'remembers the user after a browser restart' do - stub_omniauth_config(provider) - user = create(:omniauth_user, extern_uid: 'my-uid', provider: provider.to_s) - login_via(provider.to_s, user, 'my-uid', remember_me: true) - - clear_browser_session - - visit(root_path) - expect(current_path).to eq root_path - end - end - - context 'when two-factor authentication is enabled' do - it 'remembers the user after a browser restart' do - stub_omniauth_config(provider) - user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: provider.to_s) - login_via(provider.to_s, user, 'my-uid', remember_me: true) - enter_code(user.current_otp) - - clear_browser_session - - visit(root_path) - expect(current_path).to eq root_path - end - end - end - - context 'when "remember me" is not checked' do - context 'when two-factor authentication is disabled' do - it 'does not remember the user after a browser restart' do - stub_omniauth_config(provider) - user = create(:omniauth_user, extern_uid: 'my-uid', provider: provider.to_s) - login_via(provider.to_s, user, 'my-uid', remember_me: false) - - clear_browser_session - - visit(root_path) - expect(current_path).to eq new_user_session_path - end - end - - context 'when two-factor authentication is enabled' do - it 'does not remember the user after a browser restart' do - stub_omniauth_config(provider) - user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: provider.to_s) - login_via(provider.to_s, user, 'my-uid', remember_me: false) - enter_code(user.current_otp) - - clear_browser_session - - visit(root_path) - expect(current_path).to eq new_user_session_path - end - end - end - end - end -end diff --git a/spec/javascripts/fixtures/oauth_remember_me.html.haml b/spec/javascripts/fixtures/oauth_remember_me.html.haml deleted file mode 100644 index 7886e995e57..00000000000 --- a/spec/javascripts/fixtures/oauth_remember_me.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -#oauth-container - %input#remember_me{ type: "checkbox" } - - %a.oauth-login.twitter{ href: "http://example.com/" } - %a.oauth-login.github{ href: "http://example.com/" } diff --git a/spec/javascripts/oauth_remember_me_spec.js b/spec/javascripts/oauth_remember_me_spec.js deleted file mode 100644 index f90e0093d25..00000000000 --- a/spec/javascripts/oauth_remember_me_spec.js +++ /dev/null @@ -1,26 +0,0 @@ -import OAuthRememberMe from '~/oauth_remember_me'; - -describe('OAuthRememberMe', () => { - preloadFixtures('static/oauth_remember_me.html.raw'); - - beforeEach(() => { - loadFixtures('static/oauth_remember_me.html.raw'); - - new OAuthRememberMe({ container: $('#oauth-container') }).bindEvents(); - }); - - it('adds the "remember_me" query parameter to all OAuth login buttons', () => { - $('#oauth-container #remember_me').click(); - - expect($('#oauth-container .oauth-login.twitter').attr('href')).toBe('http://example.com/?remember_me=1'); - expect($('#oauth-container .oauth-login.github').attr('href')).toBe('http://example.com/?remember_me=1'); - }); - - it('removes the "remember_me" query parameter from all OAuth login buttons', () => { - $('#oauth-container #remember_me').click(); - $('#oauth-container #remember_me').click(); - - expect($('#oauth-container .oauth-login.twitter').attr('href')).toBe('http://example.com/'); - expect($('#oauth-container .oauth-login.github').attr('href')).toBe('http://example.com/'); - }); -}); diff --git a/spec/support/capybara_helpers.rb b/spec/support/capybara_helpers.rb index 3eb7bea3227..b57a3493aff 100644 --- a/spec/support/capybara_helpers.rb +++ b/spec/support/capybara_helpers.rb @@ -35,11 +35,6 @@ module CapybaraHelpers visit 'about:blank' visit url end - - # Simulate a browser restart by clearing the session cookie. - def clear_browser_session - page.driver.remove_cookie('_gitlab_session') - end end RSpec.configure do |config| diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 99e7806353d..4c88958264b 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -62,16 +62,6 @@ module LoginHelpers Thread.current[:current_user] = user end - def login_via(provider, user, uid, remember_me: false) - mock_auth_hash(provider, uid, user.email) - visit new_user_session_path - expect(page).to have_content('Sign in with') - - check 'Remember Me' if remember_me - - click_link "oauth-login-#{provider}" - end - def mock_auth_hash(provider, uid, email) # The mock_auth configuration allows you to set per-provider (or default) # authentication hashes to return during integration testing. @@ -118,7 +108,6 @@ module LoginHelpers end allow(Gitlab::OAuth::Provider).to receive_messages(providers: [:saml], config_for: mock_saml_config) stub_omniauth_setting(messages) - allow_any_instance_of(Object).to receive(:user_saml_omniauth_authorize_path).and_return('/users/auth/saml') - allow_any_instance_of(Object).to receive(:omniauth_authorize_path).with(:user, "saml").and_return('/users/auth/saml') + expect_any_instance_of(Object).to receive(:omniauth_authorize_path).with(:user, "saml").and_return('/users/auth/saml') end end -- cgit v1.2.1 From f04033654554f202fc027b359b043653177275fc Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Wed, 5 Jul 2017 16:08:53 +0000 Subject: Handles realtime with 2 states for environments table --- .../environments/components/environment.vue | 28 +++++++++------------- .../environments/components/environments_table.vue | 8 +------ .../environments/stores/environments_store.js | 22 +++++++++-------- .../environments/environments_store_spec.js | 21 ++++++++++++++++ 4 files changed, 45 insertions(+), 34 deletions(-) diff --git a/app/assets/javascripts/environments/components/environment.vue b/app/assets/javascripts/environments/components/environment.vue index 8120ef182d4..91ed8c8467f 100644 --- a/app/assets/javascripts/environments/components/environment.vue +++ b/app/assets/javascripts/environments/components/environment.vue @@ -32,7 +32,6 @@ export default { state: store.state, visibility: 'available', isLoading: false, - isLoadingFolderContent: false, cssContainerClass: environmentsData.cssClass, endpoint: environmentsData.environmentsDataEndpoint, canCreateDeployment: environmentsData.canCreateDeployment, @@ -86,9 +85,6 @@ export default { errorCallback: this.errorCallback, notificationCallback: (isMakingRequest) => { this.isMakingRequest = isMakingRequest; - - // We need to verify if any folder is open to also fecth it - this.openFolders = this.store.getOpenFolders(); }, }); @@ -119,7 +115,7 @@ export default { this.store.toggleFolder(folder); if (!folder.isOpen) { - this.fetchChildEnvironments(folder, folderUrl); + this.fetchChildEnvironments(folder, folderUrl, true); } }, @@ -147,19 +143,17 @@ export default { .catch(this.errorCallback); }, - fetchChildEnvironments(folder, folderUrl) { - this.isLoadingFolderContent = true; + fetchChildEnvironments(folder, folderUrl, showLoader = false) { + this.store.updateEnvironmentProp(folder, 'isLoadingFolderContent', showLoader); this.service.getFolderContent(folderUrl) .then(resp => resp.json()) - .then((response) => { - this.store.setfolderContent(folder, response.environments); - this.isLoadingFolderContent = false; - }) + .then(response => this.store.setfolderContent(folder, response.environments)) + .then(() => this.store.updateEnvironmentProp(folder, 'isLoadingFolderContent', false)) .catch(() => { - this.isLoadingFolderContent = false; // eslint-disable-next-line no-new new Flash('An error occurred while fetching the environments.'); + this.store.updateEnvironmentProp(folder, 'isLoadingFolderContent', false); }); }, @@ -176,13 +170,13 @@ export default { successCallback(resp) { this.saveData(resp); - // If folders are open while polling we need to open them again - if (this.openFolders.length) { - this.openFolders.map((folder) => { + // We need to verify if any folder is open to also update it + const openFolders = this.store.getOpenFolders(); + if (openFolders.length) { + openFolders.forEach((folder) => { // TODO - Move this to the backend const folderUrl = `${window.location.pathname}/folders/${folder.folderName}`; - this.store.updateFolder(folder, 'isOpen', true); return this.fetchChildEnvironments(folder, folderUrl); }); } @@ -267,7 +261,7 @@ export default { :environments="state.environments" :can-create-deployment="canCreateDeploymentParsed" :can-read-environment="canReadEnvironmentParsed" - :is-loading-folder-content="isLoadingFolderContent" /> + />