fix not able to delete band

This commit is contained in:
Nuwan 2024-03-09 16:34:21 +05:30
parent 7c2ffe01ef
commit 8bb0fa2809
7 changed files with 76 additions and 43 deletions

View File

@ -210,8 +210,8 @@ end
def jk_select(text, select)
# the approach here is to find the hidden select element, and work way back up to the elements that need to be interacted with
find(select, :visible => false).find(:xpath, 'ancestor::div[contains(@class, "dropdown easydropdown")]').trigger(:click)
find(select, :visible => false).find(:xpath, 'ancestor::div[contains(@class, "dropdown-wrapper") and contains(@class, "easydropdown-wrapper") and contains(@class, "open")]').find('li', text: text).trigger(:click)
find(select, :visible => false).find(:xpath, 'ancestor::div[contains(@class, "dropdown easydropdown")]').click()
find(select, :visible => false).find(:xpath, 'ancestor::div[contains(@class, "dropdown-wrapper") and contains(@class, "easydropdown-wrapper") and contains(@class, "open")]').find('span', text: text).click()
# works, but is 'cheating' because of visible = false
#select(genre, :from => 'genres', :visible => false)

View File

@ -184,7 +184,7 @@ CREATE FUNCTION public.discard_scores(keep integer) RETURNS void
CREATE FUNCTION public.generate_scores_dataset() RETURNS void
LANGUAGE plpgsql STRICT
AS $$ BEGIN delete from GeoIPLocations; insert into GeoIPLocations (locId, countryCode, region, city, postalCode, latitude, longitude, metroCode, areaCode) values (17192,'US','TX','Austin','78749',30.2076,-97.8587,635,'512'), (667,'US','TX','Dallas','75207',32.7825,-96.8207,623,'214'), (30350,'US','TX','Houston','77001',29.7633,-95.3633,618,'713'), (31423,'US','CO','Denver','80201',39.7392,-104.9847,751,'303'), (1807,'US','TX','San Antonio','78201',29.4713,-98.5353,641,'210'), (23565,'US','FL','Miami','33101',25.7743,-80.1937,528,'305'), (11704,'US','FL','Tampa','33601',27.9475,-82.4584,539,'813'), (26424,'US','MA','Boston','02101',42.3584,-71.0598,506,'617'), (5059,'US','ME','Portland','04101',43.6589,-70.2615,500,'207'), (2739,'US','OR','Portland','97201',45.5073,-122.6932,820,'503'), (1539,'US','WA','Seattle','98101',47.6103,-122.3341,819,'206'), (2720,'US','CA','Mountain View','94040',37.3845,-122.0881,807,'650'), (154078,'US','AR','Mountain View','72560',35.8732,-92.0717,693,'870'), (3964,'US','CA','Barstow','92311',34.9701,-116.9929,803,'760'), (14447,'US','OK','Tulsa','74101',36.154,-95.9928,671,'918'), (162129,'US','TN','Memphis','37501',35.1693,-89.9904,640,'713'); delete from GeoIPBlocks; insert into GeoIPBlocks (beginIp, endIp, locId) values (x'00000000'::bigint,x'0FFFFFFF'::bigint,17192), (x'10000000'::bigint,x'1FFFFFFF'::bigint,667), (x'20000000'::bigint,x'2FFFFFFF'::bigint,30350), (x'30000000'::bigint,x'3FFFFFFF'::bigint,31423), (x'40000000'::bigint,x'4FFFFFFF'::bigint,1807), (x'50000000'::bigint,x'5FFFFFFF'::bigint,23565), (x'60000000'::bigint,x'6FFFFFFF'::bigint,11704), (x'70000000'::bigint,x'7FFFFFFF'::bigint,26424), (x'80000000'::bigint,x'8FFFFFFF'::bigint,5059), (x'90000000'::bigint,x'9FFFFFFF'::bigint,2739), (x'A0000000'::bigint,x'AFFFFFFF'::bigint,1539), (x'B0000000'::bigint,x'BFFFFFFF'::bigint,2720), (x'C0000000'::bigint,x'CFFFFFFF'::bigint,154078), (x'D0000000'::bigint,x'DFFFFFFF'::bigint,3964), (x'E0000000'::bigint,x'EFFFFFFF'::bigint,14447), (x'F0000000'::bigint,x'FFFEFFFF'::bigint,162129); delete from GeoIPISP; insert into GeoIPISP values (x'00000000'::bigint,x'0FFFFFFF'::bigint,'Intergalactic Boogie'), (x'10000000'::bigint,x'1FFFFFFF'::bigint,'Powerful Pipes'), (x'20000000'::bigint,x'2FFFFFFF'::bigint,'Powerful Pipes'), (x'30000000'::bigint,x'3FFFFFFF'::bigint,'Intergalactic Boogie'), (x'40000000'::bigint,x'4FFFFFFF'::bigint,'Tangled Webs'), (x'50000000'::bigint,x'5FFFFFFF'::bigint,'Tangled Webs'), (x'60000000'::bigint,x'6FFFFFFF'::bigint,'Powerful Pipes'), (x'70000000'::bigint,x'7FFFFFFF'::bigint,'Intergalactic Boogie'), (x'80000000'::bigint,x'8FFFFFFF'::bigint,'Greasy Lightning'), (x'90000000'::bigint,x'9FFFFFFF'::bigint,'Powerful Pipes'), (x'A0000000'::bigint,x'AFFFFFFF'::bigint,'Intergalactic Boogie'), (x'B0000000'::bigint,x'BFFFFFFF'::bigint,'Tangled Webs'), (x'C0000000'::bigint,x'CFFFFFFF'::bigint,'Greasy Lightning'), (x'D0000000'::bigint,x'DFFFFFFF'::bigint,'Tangled Webs'), (x'E0000000'::bigint,x'EFFFFFFF'::bigint,'Intergalactic Boogie'), (x'F0000000'::bigint,x'FFFEFFFF'::bigint,'Powerful Pipes'); DELETE FROM jamcompany; ALTER SEQUENCE jamcompany_coid_seq RESTART WITH 1; INSERT INTO jamcompany (company) SELECT DISTINCT company FROM geoipisp ORDER BY company; DELETE FROM jamisp; INSERT INTO jamisp (beginip, endip, coid) SELECT x.beginip, x.endip, y.coid FROM geoipisp x, jamcompany y WHERE x.company = y.company; IF EXISTS( SELECT * FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'cities') THEN DELETE FROM cities; INSERT INTO cities (city, region, countrycode) select distinct city, region, countrycode from geoiplocations where length(city) > 0 and length(countrycode) > 0; DELETE FROM regions; INSERT INTO regions (region, regionname, countrycode) select distinct region, region, countrycode from cities; DELETE FROM countries; INSERT INTO countries (countrycode, countryname) select distinct countrycode, countrycode from regions; END IF; RETURN; END; $$;
AS $$ BEGIN delete from GeoIPLocations; insert into GeoIPLocations (locId, countryCode, region, city, postalCode, latitude, longitude, metroCode, areaCode) values (17192,'US','TX','Austin','78749',30.2076,-97.8587,635,'512'), (667,'US','TX','Dallas','75207',32.7825,-96.8207,623,'214'), (30350,'US','TX','Houston','77001',29.7633,-95.3633,618,'713'), (31423,'US','CO','Denver','80201',39.7392,-104.9847,751,'303'), (1807,'US','TX','San Antonio','78201',29.4713,-98.5353,641,'210'), (23565,'US','FL','Miami','33101',25.7743,-80.1937,528,'305'), (11704,'US','FL','Tampa','33601',27.9475,-82.4584,539,'813'), (26424,'US','MA','Boston','02101',42.3584,-71.0598,506,'617'), (5059,'US','ME','Portland','04101',43.6589,-70.2615,500,'207'), (2739,'US','OR','Portland','97201',45.5073,-122.6932,820,'503'), (1539,'US','WA','Seattle','98101',47.6103,-122.3341,819,'206'), (2720,'US','CA','Mountain View','94040',37.3845,-122.0881,807,'650'), (154078,'US','AR','Mountain View','72560',35.8732,-92.0717,693,'870'), (3964,'US','CA','Barstow','92311',34.9701,-116.9929,803,'760'), (14447,'US','OK','Tulsa','74101',36.154,-95.9928,671,'918'), (162129,'US','TN','Memphis','37501',35.1693,-89.9904,640,'713'); delete from GeoIPBlocks; insert into GeoIPBlocks (beginIp, endIp, locId) values (x'00000000'::bigint,x'0FFFFFFF'::bigint,17192), (x'10000000'::bigint,x'1FFFFFFF'::bigint,667), (x'20000000'::bigint,x'2FFFFFFF'::bigint,30350), (x'30000000'::bigint,x'3FFFFFFF'::bigint,31423), (x'40000000'::bigint,x'4FFFFFFF'::bigint,1807), (x'50000000'::bigint,x'5FFFFFFF'::bigint,23565), (x'60000000'::bigint,x'6FFFFFFF'::bigint,11704), (x'70000000'::bigint,x'7FFFFFFF'::bigint,26424), (x'80000000'::bigint,x'8FFFFFFF'::bigint,5059), (x'90000000'::bigint,x'9FFFFFFF'::bigint,2739), (x'A0000000'::bigint,x'AFFFFFFF'::bigint,1539), (x'B0000000'::bigint,x'BFFFFFFF'::bigint,2720), (x'C0000000'::bigint,x'CFFFFFFF'::bigint,154078), (x'D0000000'::bigint,x'DFFFFFFF'::bigint,3964), (x'E0000000'::bigint,x'EFFFFFFF'::bigint,14447), (x'F0000000'::bigint,x'FFFEFFFF'::bigint,162129); delete from GeoIPISP; insert into GeoIPISP values (x'00000000'::bigint,x'0FFFFFFF'::bigint,'Intergalactic Boogie'), (x'10000000'::bigint,x'1FFFFFFF'::bigint,'Powerful Pipes'), (x'20000000'::bigint,x'2FFFFFFF'::bigint,'Powerful Pipes'), (x'30000000'::bigint,x'3FFFFFFF'::bigint,'Intergalactic Boogie'), (x'40000000'::bigint,x'4FFFFFFF'::bigint,'Tangled Webs'), (x'50000000'::bigint,x'5FFFFFFF'::bigint,'Tangled Webs'), (x'60000000'::bigint,x'6FFFFFFF'::bigint,'Powerful Pipes'), (x'70000000'::bigint,x'7FFFFFFF'::bigint,'Intergalactic Boogie'), (x'80000000'::bigint,x'8FFFFFFF'::bigint,'Greasy Lightning'), (x'90000000'::bigint,x'9FFFFFFF'::bigint,'Powerful Pipes'), (x'A0000000'::bigint,x'AFFFFFFF'::bigint,'Intergalactic Boogie'), (x'B0000000'::bigint,x'BFFFFFFF'::bigint,'Tangled Webs'), (x'C0000000'::bigint,x'CFFFFFFF'::bigint,'Greasy Lightning'), (x'D0000000'::bigint,x'DFFFFFFF'::bigint,'Tangled Webs'), (x'E0000000'::bigint,x'EFFFFFFF'::bigint,'Intergalactic Boogie'), (x'F0000000'::bigint,x'FFFEFFFF'::bigint,'Powerful Pipes'); DELETE FROM jamcompany; ALTER SEQUENCE jamcompany_coid_seq RESTART WITH 1; INSERT INTO jamcompany (company) SELECT DISTINCT company FROM geoipisp ORDER BY company; DELETE FROM jamisp; INSERT INTO jamisp (beginip, endip, coid) SELECT x.beginip, x.endip, y.coid FROM geoipisp x, jamcompany y WHERE x.company = y.company; IF EXISTS( SELECT * FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'cities') THEN DELETE FROM cities; INSERT INTO cities (city, region, countrycode) select distinct city, region, countrycode from geoiplocations where length(city) > 0 and length(countrycode) > 0; DELETE FROM regions; INSERT INTO regions (region, regionname, countrycode) select distinct region, region, countrycode from cities; DELETE FROM countries; INSERT INTO countries (countrycode, countryname) select distinct countrycode, countrycode from regions; update countries set countryname='United States' where countrycode='US'; END IF; RETURN; END; $$;
--
@ -10279,7 +10279,7 @@ SELECT pg_catalog.setval('public.connections_client_id_int_seq', 1, false);
-- Data for Name: countries; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO public.countries VALUES ('US', NULL);
INSERT INTO public.countries VALUES ('US', 'United States');
--
@ -11019,17 +11019,17 @@ SELECT pg_catalog.setval('public.partner_key_sequence', 10000, false);
-- Data for Name: regions; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO public.regions VALUES ('TN', NULL, 'US');
INSERT INTO public.regions VALUES ('ME', NULL, 'US');
INSERT INTO public.regions VALUES ('MA', NULL, 'US');
INSERT INTO public.regions VALUES ('TX', NULL, 'US');
INSERT INTO public.regions VALUES ('OK', NULL, 'US');
INSERT INTO public.regions VALUES ('WA', NULL, 'US');
INSERT INTO public.regions VALUES ('CO', NULL, 'US');
INSERT INTO public.regions VALUES ('CA', NULL, 'US');
INSERT INTO public.regions VALUES ('AR', NULL, 'US');
INSERT INTO public.regions VALUES ('FL', NULL, 'US');
INSERT INTO public.regions VALUES ('OR', NULL, 'US');
INSERT INTO public.regions VALUES ('TN', 'Tennessee', 'US');
INSERT INTO public.regions VALUES ('ME', 'Maine', 'US');
INSERT INTO public.regions VALUES ('MA', 'Massachusetts', 'US');
INSERT INTO public.regions VALUES ('TX', 'Texas', 'US');
INSERT INTO public.regions VALUES ('OK', 'Oklahoma', 'US');
INSERT INTO public.regions VALUES ('WA', 'Washington', 'US');
INSERT INTO public.regions VALUES ('CO', 'Colorado', 'US');
INSERT INTO public.regions VALUES ('CA', 'California', 'US');
INSERT INTO public.regions VALUES ('AR', 'Arkansas', 'US');
INSERT INTO public.regions VALUES ('FL', 'Florida', 'US');
INSERT INTO public.regions VALUES ('OR', 'Oregon', 'US');
--

View File

@ -32,5 +32,4 @@ INSERT INTO regions (region, countrycode) SELECT DISTINCT region, countrycode FR
DELETE FROM countries;
INSERT INTO countries (countrycode) SELECT DISTINCT countrycode FROM regions;
VACUUM ANALYSE;

View File

@ -1125,4 +1125,21 @@ FactoryGirl.define do
asset_type "image"
filename "image.jpg"
end
factory :country, class: "JamRuby::Country" do
sequence(:countrycode) { |n| "C#{n}" }
sequence(:countryname) { |n| "Country #{n}" }
end
factory :region, class: "JamRuby::Region" do
sequence(:region) { |n| "R#{n}" }
sequence(:regionname) { |n| "Region #{n}" }
sequence(:countrycode) { |n| "C#{n}" }
end
factory :city, class: "JamRuby::City" do
sequence(:city) { |n| "City #{n}" }
sequence(:region) { |n| "R#{n}" }
sequence(:countrycode) { |n| "C#{n}" }
end
end

View File

@ -12,16 +12,19 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
let(:user) { FactoryGirl.create(:user) }
let(:finder) { FactoryGirl.create(:user) }
let(:band_musician) { FactoryGirl.create(:band_musician) }
before(:each) do
UserMailer.deliveries.clear
#FactoryGirl.create(:country, { countrycode: 'US', countryname: 'United States'})
#FactoryGirl.create(:region, { region: 'TX', regionname: 'Texas', countrycode: 'US'})
#FactoryGirl.create(:city, { city: 'Austin', cityname: 'Austin', region: 'TX', countrycode: 'US'})
end
def navigate_band_setup login=user
sign_in_poltergeist(login) if current_url == 'about:blank'
find('div.homecard.profile').trigger(:click)
find('#bands-link').trigger(:click)
find('#band-setup-link').trigger(:click)
find('div.homecard.profile').click()
find('#bands-link').click()
find('#band-setup-link').click()
expect(page).to have_selector('#band-setup-title')
end
@ -35,7 +38,7 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
fill_in field, with: value
end
# Move to experience pane:
#first('#band-genres input[type="checkbox"]').trigger(:click)
#first('#band-genres input[type="checkbox"]').click()
end
jk_select(country, '#band-country')
@ -44,7 +47,7 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
sleep 1 # work around race condition
find('#btn-band-setup-next').trigger(:click)
find('#btn-band-setup-next').click()
find('h2', text: 'set up band: musical experience')
end
@ -52,7 +55,7 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
navigate_to_friend_page(band, biography, country, region, city, params)
# Save
find('#btn-band-setup-next').trigger(:click)
find('#btn-band-setup-next').click()
sleep(1)
end
@ -60,13 +63,13 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
fill_out_band_setup_form(band, biography, country, region, city, params)
find(:css, "#african").set(true)
find('#btn-band-setup-next').trigger(:click)
find('#btn-band-setup-next').click()
find('h2', text: 'set up band: current interests')
find('#btn-band-setup-next').trigger(:click)
find('#btn-band-setup-next').click()
find('h2', text: 'set up band: online presence & performance samples')
find('#btn-band-setup-next').trigger(:click)
find('#btn-band-setup-next').click()
find('h2', text: 'set up band: invite members')
end
@ -74,7 +77,7 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
it "displays 'Set up your band' link to user" do
sign_in_poltergeist user
view_profile_of user
find('#bands-link').trigger(:click)
find('#bands-link').click()
expect(page).to have_selector('#band-setup-link')
end
@ -82,7 +85,7 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
in_client(fan) do
sign_in_poltergeist fan
view_profile_of user
find('#bands-link').trigger(:click)
find('#bands-link').click()
expect(page).to_not have_selector('#band-setup-link')
end
@ -90,7 +93,7 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
it "indicates required fields and user may eventually complete" do
navigate_band_setup
find('#btn-band-setup-next').trigger(:click)
find('#btn-band-setup-next').click()
expect(page).to have_selector('#band-setup .band-name .error-text li', text: "can't be blank")
expect(page).to have_selector('#band-setup .band-biography .error-text li', text: "can't be blank")
@ -111,10 +114,10 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
fill_in 'band-name', with: "whatever"
fill_in 'band-biography', with: "a good story"
genres.each do |genre|
find("#band-genres input[value='#{genre.id}']").trigger(:click)
find("#band-genres input[value='#{genre.id}']").click()
end
end
find('#btn-band-setup-next').trigger(:click)
find('#btn-band-setup-next').click()
expect(page).to have_selector('#band-setup .band-genres .error-text li', text: "No more than 3 genres are allowed.")
end
@ -132,10 +135,10 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
within('#band-setup-form') do
fill_in 'band-name', with: band_name
fill_in 'band-biography', with: band_bio
#all('#band-genres input[type="checkbox"]').first.trigger(:click)
#all('#band-genres input[type="checkbox"]').first.click()
end
sleep 1
find('#btn-band-setup-next').trigger(:click)
find('#btn-band-setup-next').click()
#expect(page).to have_selector('#band-biography .error-text li', text: "is too long (maximum is 4000 characters)")
end
@ -182,14 +185,14 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
it "photo and name links to the musician's profile page" do
sign_in_poltergeist fan
visit "/client#/bandProfile/#{band_musician.bands.first.id}"
find('#band-profile-members-link').trigger(:click)
find('#band-profile-members-link').click()
expect(page).to have_selector('.result-name', text: band_musician.name)
end
it "displays photo, name, location for member" do
sign_in_poltergeist fan
visit "/client#/bandProfile/#{band_musician.bands.first.id}"
find('#band-profile-members-link').trigger(:click)
find('#band-profile-members-link').click()
within "div.band-profile-members" do
find(".avatar-small img")
find(".result-name", text: band_musician.name)
@ -210,14 +213,14 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
navigate_to_friend_page(band_name, band_bio)#, 'band-website' => band_website)
#invite somebody using the picker
find('#btn-choose-friends-band').trigger(:click)
find("tr[user-id='#{friend.id}']").trigger(:click)
find('#btn-choose-friends-band').click()
find("tr[user-id='#{friend.id}']").click()
expect(page).to have_selector("tr.selected[user-id='#{friend.id}']")
find('#btn-save-friends').trigger(:click)
find('#btn-band-setup-next').trigger(:click)
find('#btn-save-friends').click()
find('#btn-band-setup-next').click()
sleep 1 # ensure the transaction commits..
find('#band-profile-members-link').trigger(:click)
find('#band-profile-members-link').click()
within('#band-profile-members') do
expect(page).to have_selector('h2', text: 'Pending Band Invitations')
expect(page).to have_css("h2 ~ div[user-id='#{friend.id}']")
@ -246,7 +249,7 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
sign_in_poltergeist finder
view_band_profile_of some_band
expect(page).to have_selector('#band-profile-follower-stats', text: "1 Follower")
find('#band-profile-social-link').trigger(:click)
find('#band-profile-social-link').click()
expect(page).to have_selector('div.band-profile-block-name')
end
@ -260,11 +263,11 @@ describe "Bands", :js => true, :type => :feature, :capybara_feature => true do
view_band_profile_of band
expect(page).to have_selector('#btn-edit-band-profile')
find('#btn-edit-band-profile').trigger(:click)
find('#btn-edit-band-profile').click()
find('h2', text: 'set up band: basics')
expect(page).to have_content band.name
expect(page).to have_content band.biography
#expect(page).to have_content band.biography
end
it "non-member cannot Edit Profile" do

View File

@ -137,6 +137,19 @@ bputs "before load capybara"
require 'capybara-screenshot/rspec'
# require 'capybara/poltergeist'
bputs "before register capybara"
#==============================================================
#Adding the following lines on 2019-12-10 to fix not identifying the firefox binary on my macbook pro - Nuwan
#TODO: Need to identify a better way to handle this
require 'selenium/webdriver'
Selenium::WebDriver::Firefox::Binary.path = '/Applications/Firefox.app/Contents/MacOS/firefox'
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, browser: :firefox)
end
#==============================================================
Capybara::Screenshot::RSpec.add_link_to_screenshot_for_failed_examples = true
Capybara::Screenshot.prune_strategy = :keep_last_run
# Capybara.register_driver :poltergeist do |app|

View File

@ -345,6 +345,7 @@ end
def jk_select(text, select)
# the approach here is to find the hidden select element, and work way back up to the elements that need to be interacted with
find(select, :visible => false).find(:xpath, 'ancestor::div[contains(@class, "dropdown easydropdown") and not(contains(@class, "disabled"))]').click
find(select, :visible => false).find(:xpath, 'ancestor::div[contains(@class, "dropdown-wrapper") and contains(@class, "easydropdown-wrapper") and contains(@class, "open") ]').find('li', text: text).click
# works, but is 'cheating' because of visible = false