From ad5202292786b0d18f7f3e0887ba5ab7f4079fab Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Tue, 10 Sep 2019 16:04:57 +0100 Subject: [PATCH] Add feature spec to cover api api generation in admin user edit form --- spec/features/admin/users_spec.rb | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/spec/features/admin/users_spec.rb b/spec/features/admin/users_spec.rb index 4ab504c5a4..3e4ea4c609 100644 --- a/spec/features/admin/users_spec.rb +++ b/spec/features/admin/users_spec.rb @@ -24,7 +24,7 @@ feature "Managing users" do click_link "users_email_title" end - it "should be able to list users with order email asc" do + it "should list users with order email asc" do expect(page).to have_css('table#listing_users') within("table#listing_users") do expect(page).to have_content("a@example.com") @@ -32,7 +32,7 @@ feature "Managing users" do end end - it "should be able to list users with order email desc" do + it "should list users with order email desc" do click_link "users_email_title" within("table#listing_users") do expect(page).to have_content("a@example.com") @@ -57,7 +57,7 @@ feature "Managing users" do click_link("a@example.com") end - it "should let me edit the user password" do + it "should allow editing the user password" do fill_in "user_password", :with => "welcome" fill_in "user_password_confirmation", :with => "welcome" click_button "Update" @@ -71,6 +71,23 @@ feature "Managing users" do expect(page).to have_content("The account will be updated once the new email is confirmed.") end + + it "should allow to generate, regenarate and clear the user api key", js: true do + user = Spree::User.find_by_email("a@example.com") + expect(page).to have_content "NO KEY" + + click_button "Generate API key" + first_user_api_key = user.reload.spree_api_key + expect(page).to have_content first_user_api_key + + click_button "Regenerate Key" + second_user_api_key = user.reload.spree_api_key + expect(page).to have_content second_user_api_key + expect(second_user_api_key).not_to eq first_user_api_key + + click_button "Clear key" + expect(page).to have_content "NO KEY" + end end end