From 75f5e10d04baa3bc1748b3ad81f32568d178062f Mon Sep 17 00:00:00 2001 From: Patrick Bolger Date: Sat, 24 Jun 2017 08:46:05 -0400 Subject: [PATCH] interim progress --- Gemfile | 1 + Gemfile.lock | 6 ++ .../_reason_waiting.html.haml | 14 +++-- db/schema.rb | 60 +++++++++---------- .../admin-custom-reason-waiting.feature | 4 +- .../admin-sets-custom-waiting-reason.feature | 4 +- features/support/hooks.rb | 7 ++- 7 files changed, 55 insertions(+), 41 deletions(-) diff --git a/Gemfile b/Gemfile index d53b89704..8383decb0 100644 --- a/Gemfile +++ b/Gemfile @@ -99,4 +99,5 @@ end group :test do gem 'poltergeist' + gem 'selenium-webdriver' end diff --git a/Gemfile.lock b/Gemfile.lock index 88d8765c3..32e50e931 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -108,6 +108,8 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) + childprocess (0.7.0) + ffi (~> 1.0, >= 1.0.11) chronic (0.10.2) city-state (0.0.13) rubyzip (~> 1.1) @@ -364,6 +366,9 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) + selenium-webdriver (3.4.3) + childprocess (~> 0.5) + rubyzip (~> 1.0) sexp_processor (4.8.0) shoulda-matchers (3.1.1) activesupport (>= 4.0.0) @@ -485,6 +490,7 @@ DEPENDENCIES rubyzip (>= 1.2.1) sanitize sass-rails (~> 5.0) + selenium-webdriver shoulda-matchers smarter_csv spring diff --git a/app/views/membership_applications/_reason_waiting.html.haml b/app/views/membership_applications/_reason_waiting.html.haml index 0cf475636..c8bd83000 100644 --- a/app/views/membership_applications/_reason_waiting.html.haml +++ b/app/views/membership_applications/_reason_waiting.html.haml @@ -7,20 +7,21 @@ .container .reason-waiting-information = f.label( :member_app_waiting_reasons, t('membership_applications.need_info.reason_title')) + - collection = AdminOnly::MemberAppWaitingReason.all.to_a + - collection << AdminOnly::MemberAppWaitingReason.new(id: -1, "name_#{I18n.locale.to_s}": "#{@other_waiting_reason_text}") = f.collection_select(:member_app_waiting_reasons_id, - AdminOnly::MemberAppWaitingReason.all, + collection, :id, reason_name_method, { include_blank: t('membership_applications.need_info.select_a_reason') }, - { class: 'reason-waiting-list', - onchange: 'changed_reason()' }, + { class: 'reason-waiting-list' }, ) .row .container #other-text-field = f.label( :reason_waiting_custom_text, t('membership_applications.need_info.other_reason_label') ) - = f.text_field :custom_reason_text, onchange: 'changed_custom_text()' + = f.text_field :custom_reason_text :javascript @@ -96,9 +97,10 @@ let initialize = (function() { - reasons_list.options.add(other_reason_option); // add the other_reason to the list + // reasons_list.options.add(other_reason_option); // add the other_reason to the list hideOrShowCustomReasonElements(); + $('#membership_application_member_app_waiting_reasons_id').on('change', changed_reason); + $('#membership_application_custom_reason_text').on('change', changed_custom_text) }); $(document).ready(initialize); - diff --git a/db/schema.rb b/db/schema.rb index a1bd0ac97..8012a5f44 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -15,38 +15,38 @@ # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" - create_table "addresses", force: :cascade do |t| - t.string "street_address" - t.string "post_code" - t.string "city" - t.string "country", default: "Sverige", null: false - t.integer "region_id" - t.string "addressable_type" - t.integer "addressable_id" - t.integer "kommun_id" - t.float "latitude" - t.float "longitude" + create_table "addresses", id: :bigserial, force: :cascade do |t| + t.string "street_address" + t.string "post_code" + t.string "city" + t.string "country", default: "Sverige", null: false + t.bigint "region_id" + t.string "addressable_type" + t.bigint "addressable_id" + t.bigint "kommun_id" + t.float "latitude" + t.float "longitude" t.index ["addressable_type", "addressable_id"], name: "index_addresses_on_addressable_type_and_addressable_id", using: :btree t.index ["kommun_id"], name: "index_addresses_on_kommun_id", using: :btree t.index ["latitude", "longitude"], name: "index_addresses_on_latitude_and_longitude", using: :btree t.index ["region_id"], name: "index_addresses_on_region_id", using: :btree end - create_table "business_categories", force: :cascade do |t| + create_table "business_categories", id: :bigserial, force: :cascade do |t| t.string "name" t.string "description" t.datetime "created_at", null: false t.datetime "updated_at", null: false end - create_table "business_categories_membership_applications", force: :cascade do |t| - t.integer "membership_application_id" - t.integer "business_category_id" + create_table "business_categories_membership_applications", id: :bigserial, force: :cascade do |t| + t.bigint "membership_application_id" + t.bigint "business_category_id" t.index ["business_category_id"], name: "index_on_categories", using: :btree t.index ["membership_application_id"], name: "index_on_applications", using: :btree end - create_table "ckeditor_assets", force: :cascade do |t| + create_table "ckeditor_assets", id: :bigserial, force: :cascade do |t| t.string "data_file_name", null: false t.string "data_content_type" t.integer "data_file_size" @@ -56,12 +56,12 @@ t.integer "height" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.integer "company_id" + t.bigint "company_id" t.index ["company_id"], name: "index_ckeditor_assets_on_company_id", using: :btree t.index ["type"], name: "index_ckeditor_assets_on_type", using: :btree end - create_table "companies", force: :cascade do |t| + create_table "companies", id: :bigserial, force: :cascade do |t| t.string "name" t.string "company_number" t.string "phone_number" @@ -74,13 +74,13 @@ t.index ["company_number"], name: "index_companies_on_company_number", unique: true, using: :btree end - create_table "kommuns", force: :cascade do |t| + create_table "kommuns", id: :bigserial, force: :cascade do |t| t.string "name" t.datetime "created_at", null: false t.datetime "updated_at", null: false end - create_table "member_app_waiting_reasons", force: :cascade, comment: "reasons why SHF is waiting for more info from applicant. Add more columns when more locales needed." do |t| + create_table "member_app_waiting_reasons", id: :bigserial, force: :cascade, comment: "reasons why SHF is waiting for more info from applicant. Add more columns when more locales needed." do |t| t.string "name_sv", comment: "name of the reason in svenska/Swedish" t.string "description_sv", comment: "description for the reason in svenska/Swedish" t.string "name_en", comment: "name of the reason in engelsk/English" @@ -90,23 +90,23 @@ t.datetime "updated_at", null: false end - create_table "member_pages", force: :cascade do |t| + create_table "member_pages", id: :bigserial, force: :cascade do |t| t.string "filename", null: false t.string "title" t.datetime "created_at", null: false t.datetime "updated_at", null: false end - create_table "membership_applications", force: :cascade do |t| + create_table "membership_applications", id: :bigserial, force: :cascade do |t| t.string "company_number" t.string "phone_number" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.integer "user_id" + t.bigint "user_id" t.string "first_name" t.string "last_name" t.string "contact_email" - t.integer "company_id" + t.bigint "company_id" t.string "membership_number" t.string "state", default: "new" t.integer "member_app_waiting_reasons_id" @@ -116,15 +116,15 @@ t.index ["user_id"], name: "index_membership_applications_on_user_id", using: :btree end - create_table "regions", force: :cascade do |t| + create_table "regions", id: :bigserial, force: :cascade do |t| t.string "name" t.string "code" t.datetime "created_at", null: false t.datetime "updated_at", null: false end - create_table "shf_documents", force: :cascade do |t| - t.integer "uploader_id", null: false + create_table "shf_documents", id: :bigserial, force: :cascade do |t| + t.bigint "uploader_id", null: false t.string "title" t.text "description" t.datetime "created_at", null: false @@ -136,18 +136,18 @@ t.index ["uploader_id"], name: "index_shf_documents_on_uploader_id", using: :btree end - create_table "uploaded_files", force: :cascade do |t| + create_table "uploaded_files", id: :bigserial, force: :cascade do |t| t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "actual_file_file_name" t.string "actual_file_content_type" t.integer "actual_file_file_size" t.datetime "actual_file_updated_at" - t.integer "membership_application_id" + t.bigint "membership_application_id" t.index ["membership_application_id"], name: "index_uploaded_files_on_membership_application_id", using: :btree end - create_table "users", force: :cascade do |t| + create_table "users", id: :bigserial, force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" diff --git a/features/membership-application-status/admin-custom-reason-waiting.feature b/features/membership-application-status/admin-custom-reason-waiting.feature index 56e294029..dd7e6254b 100644 --- a/features/membership-application-status/admin-custom-reason-waiting.feature +++ b/features/membership-application-status/admin-custom-reason-waiting.feature @@ -17,7 +17,7 @@ Feature: "Other/Custom" waiting reason comes from locale file and Admin cannot e Background: # it is important that this statement is first so that tables are empty, so that things will be seeded - Given the system is seeded with initial data + # Given the system is seeded with initial data Given the following users exists @@ -55,7 +55,7 @@ Feature: "Other/Custom" waiting reason comes from locale file and Admin cannot e And I am logged in as "admin@shf.se" - @admin + @admin @javascript Scenario: The "other/custom" reason is listed as a reason for the 'waiting for...' status Given I am on "AnnaWaiting" application page Then "membership_application_member_app_waiting_reasons_id" should have t("admin_only.member_app_waiting_reasons.other_custom_reason") as an option diff --git a/features/membership-application-status/admin-sets-custom-waiting-reason.feature b/features/membership-application-status/admin-sets-custom-waiting-reason.feature index 62115b63f..861ebf272 100644 --- a/features/membership-application-status/admin-sets-custom-waiting-reason.feature +++ b/features/membership-application-status/admin-sets-custom-waiting-reason.feature @@ -33,7 +33,6 @@ Feature: Admin sets or enters the reason they are waiting for info from a user And the following member app waiting reasons exist | name_sv | description_sv | name_en | description_en | is_custom | - | Annat (skriv in orsaken) | Annat | Other (enter the reason) | other | false | | need doc | need doc | need documentation | need more documents proving qualifications | false | | waiting for payment | still waiting for payment | waiting for payment | still waiting for payment | false | @@ -47,8 +46,10 @@ Feature: Admin sets or enters the reason they are waiting for info from a user Scenario: Admin selects 'need more documentation' as the reason SHF is waiting_for_applicant Given I am on "AnnaWaiting" application page When I set "membership_application_member_app_waiting_reasons_id" to "need doc" + And show me the page And I am on the list applications page And I am on "AnnaWaiting" application page + And show me the page Then "membership_application_member_app_waiting_reasons_id" should have "need doc" selected And I should not see t("admin_only.member_app_waiting_reasons.other_custom_reason") @@ -104,4 +105,3 @@ Feature: Admin sets or enters the reason they are waiting for info from a user Given I am logged in as "anna_waiting_for_info@nosnarkybarky.se" And I am on the application page for "AnnaWaiting" Then I should not see t("membership_applications.need_info.reason_title") - diff --git a/features/support/hooks.rb b/features/support/hooks.rb index 40bbd5012..60338bb2d 100644 --- a/features/support/hooks.rb +++ b/features/support/hooks.rb @@ -2,7 +2,12 @@ Capybara.current_driver = :poltergeist end -After('@javascript, @poltergeist') do +Before('@selenium') do + # For JS-driven tests that Poltergeist does not handle cleanly. + Capybara.javascript_driver = :selenium +end + +After('@javascript, @poltergeist, @selenium') do Capybara.reset_sessions! Capybara.current_driver = :rack_test end