From 7f842fc8c3b890383138f3193c3a76aa603bda94 Mon Sep 17 00:00:00 2001 From: andersen Date: Thu, 1 Jun 2017 15:18:10 -0500 Subject: [PATCH 01/15] Add middleware to support filtering of invalid requests --- config/application.rb | 1 + config/initializers/invalid_data_interceptor.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 config/initializers/invalid_data_interceptor.rb diff --git a/config/application.rb b/config/application.rb index a34b3ce9..37007bc5 100644 --- a/config/application.rb +++ b/config/application.rb @@ -15,5 +15,6 @@ class Application < Rails::Application # Set default time zone config.time_zone = 'Central Time (US & Canada)' + config.middleware.insert_before Rack::Runtime, 'InvalidDataInterceptor' end end diff --git a/config/initializers/invalid_data_interceptor.rb b/config/initializers/invalid_data_interceptor.rb new file mode 100644 index 00000000..91459510 --- /dev/null +++ b/config/initializers/invalid_data_interceptor.rb @@ -0,0 +1,17 @@ +class InvalidDataInterceptor + def initialize(app) + @app = app + end + + def call(env) + query = Rack::Utils.parse_nested_query(env['QUERY_STRING'].to_s) rescue :bad_query + + headers = { 'Content-Type' => 'text/plain' } + + if query == :bad_query + [400, headers, ['Bad Request']] + else + @app.call(env) + end + end +end \ No newline at end of file From 997697b0ca1dc88a637c685a5197c7c70adb9d97 Mon Sep 17 00:00:00 2001 From: andersen Date: Mon, 26 Jun 2017 14:06:28 -0500 Subject: [PATCH 02/15] =?UTF-8?q?Disable=20form=20buttons=20on=20submit,?= =?UTF-8?q?=20and=20add=20=E2=80=9Cprogress=E2=80=9D=20pointers=20to=20let?= =?UTF-8?q?=20the=20user=20know=20something=20is=20happening?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/javascripts/urls.js | 16 +++++++++++++++- app/assets/stylesheets/urls.scss | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/urls.js b/app/assets/javascripts/urls.js index 4f1aa033..45d72774 100644 --- a/app/assets/javascripts/urls.js +++ b/app/assets/javascripts/urls.js @@ -2,6 +2,20 @@ $(document).on("click", ".cancel-new-url", function(e) { e.preventDefault(); $(this).closest("tr").remove(); }); +$(document).on({ + ajaxStart: function () { + $('body').css( 'cursor', 'progress' ); + $('a').css( 'cursor', 'progress' ); + }, + ajaxStop: function () { + $('body').css( 'cursor', '' ); + $('a').css( 'cursor', '' ); + } +}); + +$(document).on("submit", "form", function(e) { + $(this).find(":submit").prop("disabled", true); +}); $(document).on("click", ".cancel-edit", function(e) { e.preventDefault(); @@ -231,7 +245,7 @@ function initializeUrlDataTable(sortColumn, sortOrder, actionColumn, keywordColu return false; } - //else, update its old stored value. + //else, update its old stored value. $target.data("prev", this.value); }); }); diff --git a/app/assets/stylesheets/urls.scss b/app/assets/stylesheets/urls.scss index 068f0b24..8e2abe3e 100644 --- a/app/assets/stylesheets/urls.scss +++ b/app/assets/stylesheets/urls.scss @@ -1,5 +1,9 @@ @import 'variables'; +button:disabled { + opacity: 0.65; +} + .url { display: inline; } From 53b009a61b6430dd1ca005224ef06bf4c008218f Mon Sep 17 00:00:00 2001 From: andersen Date: Mon, 26 Jun 2017 14:10:31 -0500 Subject: [PATCH 03/15] Add the style to the buttons too --- app/assets/javascripts/urls.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/assets/javascripts/urls.js b/app/assets/javascripts/urls.js index 45d72774..b41b1c4c 100644 --- a/app/assets/javascripts/urls.js +++ b/app/assets/javascripts/urls.js @@ -6,10 +6,12 @@ $(document).on({ ajaxStart: function () { $('body').css( 'cursor', 'progress' ); $('a').css( 'cursor', 'progress' ); + $('button').css( 'cursor', 'progress' ); }, ajaxStop: function () { $('body').css( 'cursor', '' ); $('a').css( 'cursor', '' ); + $('button').css( 'cursor', '' ); } }); From b4c817eac0fd989b805daf0bd10d6f5b55b85efa Mon Sep 17 00:00:00 2001 From: andersen Date: Wed, 28 Jun 2017 13:50:48 -0500 Subject: [PATCH 04/15] Fix typo --- config/locales/en.bootstrap.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/en.bootstrap.yml b/config/locales/en.bootstrap.yml index e9ee5d20..24af8809 100644 --- a/config/locales/en.bootstrap.yml +++ b/config/locales/en.bootstrap.yml @@ -81,7 +81,7 @@ en: title: "API" urls: copy_success: "Copied shortlink to clipboard" - move_confirm: "Are you sure you with to move short URL {{keyword}} to collection {{collection}}?" + move_confirm: "Are you sure you wish to move short URL {{keyword}} to collection {{collection}}?" transfer_button: "Give to a different user" move_button: "Move to a different collection" index: From 783b9e57e2e9aea62ba3de6684e8495038ee3cca Mon Sep 17 00:00:00 2001 From: andersen Date: Wed, 28 Jun 2017 14:44:33 -0500 Subject: [PATCH 05/15] Add what's new in Z link to nav bar --- app/views/layouts/_navigation_top.html.erb | 1 + config/locales/en.bootstrap.yml | 1 + config/routes.rb | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/_navigation_top.html.erb b/app/views/layouts/_navigation_top.html.erb index fcfbd54f..a6ded5a5 100644 --- a/app/views/layouts/_navigation_top.html.erb +++ b/app/views/layouts/_navigation_top.html.erb @@ -49,6 +49,7 @@ diff --git a/config/locales/en.bootstrap.yml b/config/locales/en.bootstrap.yml index e9ee5d20..c6302c52 100644 --- a/config/locales/en.bootstrap.yml +++ b/config/locales/en.bootstrap.yml @@ -38,6 +38,7 @@ en: help: "Help" contact_us: "Contact Us!" faq: "Read our FAQ" + whatsnew: "What's New in Z" org_url: "http://latis.umn.edu/" admin: all_urls: "View all URLs" diff --git a/config/routes.rb b/config/routes.rb index c60b9ee7..6d23e6d5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,7 +18,7 @@ root 'home#index' get 'shortener', to: 'urls#index' - get "/pages/:page" => "pages#show" + get "/pages/:page" => "pages#show", as: :pages # This will allow us to run the meat of the app at z.umn.edu/shortener and # assume that all other z.umn.edu/:keywords are requests for short urls. From 01440c54b799dd6490f41c31faab8c58ca616a24 Mon Sep 17 00:00:00 2001 From: andersen Date: Thu, 29 Jun 2017 13:26:07 -0500 Subject: [PATCH 06/15] Add test for link visibility --- spec/features/layout_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/features/layout_spec.rb b/spec/features/layout_spec.rb index bdfce63e..5a8c76b3 100644 --- a/spec/features/layout_spec.rb +++ b/spec/features/layout_spec.rb @@ -34,5 +34,10 @@ it 'should have a Collections link' do expect(page).to have_link 'Collections' end + + it 'should have a Whats new link' do + click_link 'Help' + expect(page).to have_link "What's New in Z" + end end end From 1fb57d57e8aa8c7fd0e6d9c6ec3b4b501ea7f3b4 Mon Sep 17 00:00:00 2001 From: Bernard Ferguson Date: Fri, 30 Jun 2017 16:24:53 -0500 Subject: [PATCH 07/15] move bulk table acions into a new bulk actions drop down. implement new bulk delete functionality --- app/assets/javascripts/urls.js | 66 ++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/urls.js b/app/assets/javascripts/urls.js index 4f1aa033..0a4ed593 100644 --- a/app/assets/javascripts/urls.js +++ b/app/assets/javascripts/urls.js @@ -92,6 +92,7 @@ $(document).on('shown.bs.tab', function(e) { } }) +//these three should be one function. function transferUrl(transferPath, keywords) { $.ajax({ url: transferPath, @@ -101,7 +102,15 @@ function transferUrl(transferPath, keywords) { dataType: 'script' }); } - +function batchDelete(batchDeletePath, keywords) { + $.ajax({ + url: batchDeletePath, + data: { + keywords: keywords + }, + dataType: 'script' + }); +} function moveUrl(movePath, keywords) { $.ajax({ url: movePath, @@ -126,6 +135,8 @@ function changeGroup(groupPath, keyword) { function initializeUrlDataTable(sortColumn, sortOrder, actionColumn, keywordColumn, showMoveButton, collectionSelect) { var transferText = ' ' + I18n.t("views.urls.transfer_button"); var moveText = ' ' + I18n.t("views.urls.move_button"); + var batchDeleteText = ' ' + I18n.t("views.urls.batch_delete_button"); + var bulkActionsText = I18n.t("views.urls.bulk_actions") + ' '; var $urlsTable = $('#urls-table'); var userTable = $urlsTable.DataTable({ @@ -204,6 +215,8 @@ function initializeUrlDataTable(sortColumn, sortOrder, actionColumn, keywordColu } }, fnDrawCallback: function() { + enableDisableTableOptions(); + //for all the select pickers in the table $("table#urls-table .selectpicker").each(function(index, selectPicker) { @@ -231,7 +244,7 @@ function initializeUrlDataTable(sortColumn, sortOrder, actionColumn, keywordColu return false; } - //else, update its old stored value. + //else, update its old stored value. $target.data("prev", this.value); }); }); @@ -254,6 +267,23 @@ function initializeUrlDataTable(sortColumn, sortOrder, actionColumn, keywordColu $(".loading-indicator-wrapper").remove(); } }); + + //function for disabling bulk table options dropdown + function enableDisableTableOptions(){ + var selectedRows = userTable.rows('.selected'); + if (selectedRows[0].length){ + $(".table-options").removeClass("disabled"); + } + else{ + $(".table-options").addClass("disabled"); + + } + } + + //use the function for disabling bulk table options dropdown + userTable.on('select', enableDisableTableOptions); + userTable.on('deselect', enableDisableTableOptions); + $('table.data-table').on("page.dt", function(e) { userTable.rows().deselect(); $("#select-all").prop("checked", false); @@ -267,7 +297,7 @@ function initializeUrlDataTable(sortColumn, sortOrder, actionColumn, keywordColu var transfer_button = { extend: 'selected', text: transferText, - className: 'btn-primary js-transfer-urls', + className: 'btn js-transfer-urls', action: function(e, dt, node, config) { var keywords = []; userTable.rows('.selected').data().map(function(row) { @@ -279,7 +309,7 @@ function initializeUrlDataTable(sortColumn, sortOrder, actionColumn, keywordColu var move_button = { extend: 'selected', - className: 'btn-primary js-move-urls', + className: 'btn js-move-urls', text: moveText, action: function(e, dt, node, config) { var keywords = []; @@ -291,15 +321,38 @@ function initializeUrlDataTable(sortColumn, sortOrder, actionColumn, keywordColu } } + var batch_delete_button = { + extend: 'selected', + className: 'btn btn-danger js-delete-urls', + text: batchDeleteText, + action: function(e, dt, node, config) { + var keywords = []; + userTable.rows('.selected').data().map(function(row) { + keywords.push(row['DT_RowData']['keyword']) + }); + + batchDelete($('.route-info').data('new-batch-delete-path'), keywords); + } + } + buttons = [] if (showMoveButton) { - buttons = [transfer_button, move_button] + buttons = [transfer_button, move_button, batch_delete_button] } else { buttons = [transfer_button] } - new $.fn.dataTable.Buttons(userTable, { + var dropdown_button = { + extend: 'collection', + text: bulkActionsText, + className: 'table-options', + autoClose: true, + fade: 200, buttons: buttons + } + + new $.fn.dataTable.Buttons(userTable, { + buttons: [dropdown_button] }); userTable @@ -310,7 +363,6 @@ function initializeUrlDataTable(sortColumn, sortOrder, actionColumn, keywordColu $(".col-sm-6 .dt-buttons").removeClass("btn-group"); } - $(document).ready(function() { //url share actions $("[data-toggle='tooltip']").tooltip(); From 2e78ad3979f4e1b317e54a8f75d957ac5363b761 Mon Sep 17 00:00:00 2001 From: Bernard Ferguson Date: Fri, 30 Jun 2017 16:25:01 -0500 Subject: [PATCH 08/15] implement new bulk delete functionality --- app/assets/stylesheets/layout.scss | 8 ++++++ app/controllers/batch_delete_controller.rb | 29 ++++++++++++++++++++++ app/views/batch_delete/_new_modal.html.erb | 28 +++++++++++++++++++++ app/views/batch_delete/new.js.erb | 2 ++ 4 files changed, 67 insertions(+) create mode 100644 app/controllers/batch_delete_controller.rb create mode 100644 app/views/batch_delete/_new_modal.html.erb create mode 100644 app/views/batch_delete/new.js.erb diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 157f1e6f..d86c54b5 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -229,6 +229,10 @@ though the color below doesn't improve much. margin-right: 5%; } +.padding-left-right{ + padding-left:20px; + padding-right:20px; +} #left_text { text-align: left; font-size: 1em; @@ -702,6 +706,10 @@ div.dataTables_wrapper{ } } +.modal-body{ + word-wrap:break-word; +} + #starburst-close { display: none; } diff --git a/app/controllers/batch_delete_controller.rb b/app/controllers/batch_delete_controller.rb new file mode 100644 index 00000000..fb15806f --- /dev/null +++ b/app/controllers/batch_delete_controller.rb @@ -0,0 +1,29 @@ +class BatchDeleteController < ApplicationController + def new + @urls = Url + .where(keyword: params[:keywords]) + + respond_to do |format| + format.html + format.js { render 'batch_delete/new', layout: false } + end + end + + def create + Url.where(keyword: params[:keywords]).destroy_all + respond_to do |format| + format.js do + redirect_to urls_path + end + # + # respond_to do |format| + # if + # format.js do + # redirect_to urls_path + # end + # else + # format.js { render 'batch_delete/new', layout: false } + # end + end + end +end diff --git a/app/views/batch_delete/_new_modal.html.erb b/app/views/batch_delete/_new_modal.html.erb new file mode 100644 index 00000000..4c8750b1 --- /dev/null +++ b/app/views/batch_delete/_new_modal.html.erb @@ -0,0 +1,28 @@ + diff --git a/app/views/batch_delete/new.js.erb b/app/views/batch_delete/new.js.erb new file mode 100644 index 00000000..c7082e60 --- /dev/null +++ b/app/views/batch_delete/new.js.erb @@ -0,0 +1,2 @@ +$("#index-modal").html($("<%= escape_javascript(render(partial: 'batch_delete/new_modal')) %>")) +$("#index-modal").modal() From 8d5dd8757f00fd6bb751a02ef7a6afb26e355860 Mon Sep 17 00:00:00 2001 From: Bernard Ferguson Date: Fri, 30 Jun 2017 16:25:18 -0500 Subject: [PATCH 09/15] new phrases for bulk delete and bulk actions dropdown --- config/locales/en.bootstrap.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/config/locales/en.bootstrap.yml b/config/locales/en.bootstrap.yml index e9ee5d20..6c7db78d 100644 --- a/config/locales/en.bootstrap.yml +++ b/config/locales/en.bootstrap.yml @@ -84,6 +84,8 @@ en: move_confirm: "Are you sure you with to move short URL {{keyword}} to collection {{collection}}?" transfer_button: "Give to a different user" move_button: "Move to a different collection" + batch_delete_button: "Delete" + bulk_actions: "Bulk Actions" index: transfer_requests: to_others: "URLs you gave that are pending approval" @@ -229,3 +231,10 @@ en: submit: "Move URLs" submit_confirm: "Are you sure you want to move these URLs?" cancel: "Cancel" + batch_delete: + new: + title: "Delete URLs" + urls_title: "URLs you are deleting" + submit: "Delete URLs" + submit_confirm: "Are you sure you want to delete these URLs?" + cancel: "Cancel" From 72976bd5f1225d9a964f52e5fa0a515889369167 Mon Sep 17 00:00:00 2001 From: Bernard Ferguson Date: Fri, 30 Jun 2017 16:25:23 -0500 Subject: [PATCH 10/15] update schema --- db/schema.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index 3557bdf4..adaca918 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -17,6 +17,7 @@ t.integer "url_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.index ["url_id"], name: "index_clicks_on_url_id", using: :btree end create_table "frequently_asked_questions", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| @@ -42,7 +43,7 @@ t.index ["user_id"], name: "index_groups_users_on_user_id", using: :btree end - create_table "perid_umndid", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" do |t| + create_table "perid_umndid", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| t.string "perid" t.string "umndid" t.string "uid" @@ -124,6 +125,7 @@ t.index ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id", using: :btree end + add_foreign_key "clicks", "urls" add_foreign_key "groups_users", "groups" add_foreign_key "groups_users", "users" add_foreign_key "transfer_request_urls", "transfer_requests" From 7ce869fe47e44beaa8889a260a79af0708af474a Mon Sep 17 00:00:00 2001 From: Bernard Ferguson Date: Fri, 30 Jun 2017 16:25:30 -0500 Subject: [PATCH 11/15] update tests --- spec/features/transfer_request_spec.rb | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/spec/features/transfer_request_spec.rb b/spec/features/transfer_request_spec.rb index 28dc0b41..9b81dd3d 100644 --- a/spec/features/transfer_request_spec.rb +++ b/spec/features/transfer_request_spec.rb @@ -12,9 +12,9 @@ end describe 'with no urls' do - describe 'the transfer button' do + describe 'the bulk actions button ' do it 'should be disabled' do - expect(page.find('.js-transfer-urls')[:class]).to( + expect(page.find('.table-options')[:class]).to( have_content('disabled') ) end @@ -26,12 +26,13 @@ FactoryGirl.create(:url, group: @user.context_group) FactoryGirl.create(:url, group: @user.context_group) visit urls_path + wait_for_ajax end describe 'with no urls selected' do - describe 'the transfer button', js: true do + describe 'the bulk actions button ', js: true do it 'should be disabled' do - expect(page.find('.js-transfer-urls')[:class]).to( + expect(page.find('.table-options')[:class]).to( have_content('disabled') ) end @@ -48,6 +49,7 @@ visit urls_path find("#url-#{@selected_url.id} > .select-checkbox").click find("#url-#{@new_group_url.id} > .select-checkbox").click + find('.table-options').click find('.js-transfer-urls').click wait_for_ajax end @@ -77,14 +79,11 @@ describe 'with a single url selected' do - before { find("#url-#{@selected_url.id} > .select-checkbox").click } - describe 'the transfer button' do - it 'should be enabled' do - expect(page.find('.js-transfer-urls')[:class]).to_not( - have_content('disabled') - ) - end - end + before { + find("#url-#{@selected_url.id} > .select-checkbox").click + wait_for_ajax + find('.table-actions').click + } describe 'clicking the tranfser button' do before do From 3dedd0c3b719df4d9e1a3b26318cf6aa549ebce8 Mon Sep 17 00:00:00 2001 From: Bernard Ferguson Date: Fri, 30 Jun 2017 16:25:42 -0500 Subject: [PATCH 12/15] new routes for batch delete --- config/routes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/routes.rb b/config/routes.rb index c60b9ee7..3b419f17 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -71,6 +71,7 @@ end resources :move_to_group, only: [:new, :create] + resources :batch_delete, only: [:new, :create] # groups groups index get # groups/:id groups show get From 82160b1c26a21bef49c61bf08f4866ec3ebacd1b Mon Sep 17 00:00:00 2001 From: Bernard Ferguson Date: Fri, 30 Jun 2017 16:25:48 -0500 Subject: [PATCH 13/15] new styles --- app/assets/stylesheets/urls.scss | 41 ++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/urls.scss b/app/assets/stylesheets/urls.scss index 068f0b24..a5941c88 100644 --- a/app/assets/stylesheets/urls.scss +++ b/app/assets/stylesheets/urls.scss @@ -207,6 +207,7 @@ table.dataTable{ // box-shadow: 1px 1px 2px rgba(0,0,0,0.1), -1px 1px 2px rgba(0,0,0,0.1); font-size:13px; border: 1px solid #ddd; + .short-url{ font-weight:500; // white-space:nowrap; @@ -224,6 +225,10 @@ table.dataTable{ /* display: inline-block; */ } } + tbody tr td .dropdown .dropdown-menu.dropdown-menu-right a{ + color:black; + } + .long-url{ margin-top:1px; a{ @@ -313,7 +318,6 @@ table.dataTable{ input{ margin:0; } - } .z-hero-title{ color: #666; @@ -326,6 +330,39 @@ table.dataTable{ width:300px !important; } } +.table-options{ + &.disabled{ + cursor: not-allowed; + } + i{ + margin-left: 5px !important; + vertical-align: top; + } +} +.dt-button-collection.dropdown-menu{ + padding:0; + overflow:hidden; + li.btn{ + padding:0; + display:block; + text-align:left; + a{ + padding: 14px 32px; + } + &.btn-danger{ + border-radius:0; + border:none; + color:white; + a{ + color:white; + &:hover{ + background-color: transparent; + } + } + } + + } +} @media screen and (max-width:900px){ .table-row-edit-main{ .super-input{ @@ -333,7 +370,6 @@ table.dataTable{ width:100px; } } - } } table.dataTable thead .sorting:after, table.dataTable thead .sorting_asc:after, table.dataTable thead .sorting_desc:after, table.dataTable thead .sorting_asc_disabled:after, table.dataTable thead .sorting_desc_disabled:after{ @@ -737,6 +773,7 @@ $superInputHeight: 50px; overflow:hidden; } } + .dropdown-menu{ padding:0; a{ From ed04d58d9c2128346b005ad51eeabe6902863a15 Mon Sep 17 00:00:00 2001 From: Bernard Ferguson Date: Fri, 30 Jun 2017 16:26:08 -0500 Subject: [PATCH 14/15] add url path for bulk delete action --- app/views/urls/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/urls/index.html.erb b/app/views/urls/index.html.erb index 9b1b7cbf..1ed8fba4 100644 --- a/app/views/urls/index.html.erb +++ b/app/views/urls/index.html.erb @@ -38,7 +38,7 @@ -<%= content_tag :div, class: "route-info", data: {new_transfer_request_path: new_transfer_request_path, new_move_to_group_path: new_move_to_group_path, new_group_path: new_group_path} do %> +<%= content_tag :div, class: "route-info", data: {new_transfer_request_path: new_transfer_request_path, new_move_to_group_path: new_move_to_group_path, new_group_path: new_group_path, new_batch_delete_path: new_batch_delete_path} do %> <% end %> <%= content_tag :div, class: "collection-selected", data: {collection_selected: params[:collection]} do %> From 2e8c7313b91e9d48fc6b330f09c162878f9c7bfb Mon Sep 17 00:00:00 2001 From: Bernard Ferguson Date: Wed, 5 Jul 2017 13:20:52 -0500 Subject: [PATCH 15/15] updated tests --- spec/features/admin/transfer_request_spec.rb | 10 +++++-- spec/features/groups_spec.rb | 1 + spec/features/move_group_spec.rb | 31 +++++++------------- spec/features/transfer_request_spec.rb | 5 ++-- 4 files changed, 21 insertions(+), 26 deletions(-) diff --git a/spec/features/admin/transfer_request_spec.rb b/spec/features/admin/transfer_request_spec.rb index 97e0cbc7..313d9a8b 100644 --- a/spec/features/admin/transfer_request_spec.rb +++ b/spec/features/admin/transfer_request_spec.rb @@ -14,7 +14,7 @@ describe 'with no urls' do describe 'the transfer button' do it 'should be disabled' do - expect(page.find('.js-transfer-urls')[:class]).to( + expect(page.find('.table-options')[:class]).to( have_content('disabled') ) end @@ -28,11 +28,13 @@ FactoryGirl.create(:url, group: @user.context_group) FactoryGirl.create(:url, group: @user.context_group) visit admin_urls_path + wait_for_ajax end describe 'as an admin' do describe ' and not in the group of of the url' do before do find("#url-#{@users_url.id} > .select-checkbox").click + page.find('.table-options').click page.find('.js-transfer-urls').click wait_for_ajax @to_user = FactoryGirl.create(:user) @@ -48,6 +50,7 @@ describe 'and in the group of the url' do before do find("#url-#{@admins_url.id} > .select-checkbox").click + page.find('.table-options').click page.find('.js-transfer-urls').click wait_for_ajax @to_user = FactoryGirl.create(:user) @@ -64,7 +67,7 @@ describe 'with no urls selected' do describe 'the transfer button' do it 'should be disabled' do - expect(page.find('.js-transfer-urls')[:class]).to( + expect(page.find('.table-options')[:class]).to( have_content('disabled') ) end @@ -77,7 +80,7 @@ end describe 'the transfer button' do it 'should be enabled' do - expect(page.find('.js-transfer-urls')[:class]).to_not( + expect(page.find('.table-options')[:class]).to_not( have_content('disabled') ) end @@ -85,6 +88,7 @@ describe 'clicking the transfer button' do before do + page.find('.table-options').click page.find('.js-transfer-urls').click wait_for_ajax end diff --git a/spec/features/groups_spec.rb b/spec/features/groups_spec.rb index 0085bdc7..8e669194 100644 --- a/spec/features/groups_spec.rb +++ b/spec/features/groups_spec.rb @@ -72,6 +72,7 @@ sign_in @user wait_for_ajax visit groups_path + wait_for_ajax end describe 'page content' do diff --git a/spec/features/move_group_spec.rb b/spec/features/move_group_spec.rb index 9d9f247e..5277e714 100644 --- a/spec/features/move_group_spec.rb +++ b/spec/features/move_group_spec.rb @@ -14,26 +14,15 @@ visit urls_path end - describe 'with no extra groups' do - describe 'the move group button' do - it 'should not be visible' do - expect(page).to_not have_link 'Move to a different group' - end - end - end - describe 'with extra groups' do before do visit urls_path end describe 'without urls' do - describe 'the move collection button' do - it 'should be visible' do - expect(page).to have_link 'Move to a different collection' - end + describe 'the table bulk actions button' do it 'should be disabled' do - expect(page.find_link('Move to a different collection')[:class]).to( + expect(page.find('.table-options')[:class]).to( have_content('disabled') ) end @@ -47,12 +36,9 @@ end describe 'none selected' do - describe 'the move group button' do - it 'should be visible' do - expect(page).to have_link 'Move to a different collection' - end + describe 'the table buld actions button' do it 'should be disabled' do - expect(page.find('.js-move-urls')[:class]).to( + expect(page.find('.table-options')[:class]).to( have_content('disabled') ) end @@ -64,16 +50,19 @@ find("#url-#{@url.id} .select-checkbox").click end - describe 'the move group button' do + describe 'the table bulk actions button' do it 'should be enabled' do - expect(page.find('.js-move-urls')[:class]).to_not( + expect(page.find('.table-options')[:class]).to_not( have_content('disabled') ) end end describe 'clicking the move group button' do - before { click_link 'Move to a different collection' } + before { + find('.table-options').click + click_link 'Move to a different collection' + } it 'should display the modal' do expect(page).to have_selector('#index-modal', visible: true) end diff --git a/spec/features/transfer_request_spec.rb b/spec/features/transfer_request_spec.rb index 9b81dd3d..ddc01be9 100644 --- a/spec/features/transfer_request_spec.rb +++ b/spec/features/transfer_request_spec.rb @@ -9,6 +9,7 @@ describe 'on the urls index page' do before do visit urls_path + wait_for_ajax end describe 'with no urls' do @@ -77,12 +78,12 @@ end end - describe 'with a single url selected' do before { + visit urls_path find("#url-#{@selected_url.id} > .select-checkbox").click wait_for_ajax - find('.table-actions').click + find('.table-options').click } describe 'clicking the tranfser button' do