Permalink
Browse files

Remove geoip lookup and always show cookie banner

  • Loading branch information...
seadowg committed Jul 11, 2018
1 parent 29d888a commit dc357d40bf7805bfeabe9df8a1014dd12d590ff3
@@ -59,30 +59,24 @@
select_last_tab
expect(page).to have_content 'Lorem ipsum'
end
end
describe 'visiting the home page in the EU' do
before do
visit_home_page('DE')
end
specify 'sees banner with terms, privacy and cookie warning' do
within(".banner") do
expect(find_link('Terms of Use')[:href]).to eq("https://loripsum.net/api")
expect(find_link('Terms of Use')[:target]).to eq("_blank")
specify 'sees banner with terms, privacy and cookie warning' do
within(".banner") do
expect(find_link('Terms of Use')[:href]).to eq("https://loripsum.net/api")
expect(find_link('Terms of Use')[:target]).to eq("_blank")
expect(find_link('Privacy Policy')[:href]).to eq("https://baconipsum.com/api/?type=all-meat&paras=1&start-with-lorem=1&format=html")
expect(find_link('Privacy Policy')[:target]).to eq("_blank")
expect(find_link('Privacy Policy')[:href]).to eq("https://baconipsum.com/api/?type=all-meat&paras=1&start-with-lorem=1&format=html")
expect(find_link('Privacy Policy')[:target]).to eq("_blank")
expect(page).to have_content('use of cookies')
end
expect(page).to have_content('use of cookies')
end
click_on "OK"
expect(page).not_to have_css(".banner")
click_on "OK"
expect(page).not_to have_css(".banner")
visit_home_page
expect(page).not_to have_css(".banner")
end
visit_home_page
expect(page).not_to have_css(".banner")
end
end
describe 'joining private retro' do
View
@@ -35,9 +35,6 @@ const RetroApi = {
apiBaseUrl() {
return global.Retro.config.api_base_url;
},
ipCheckerUrl() {
return "https://freegeoip.net/json/";
},
createRetro(data) {
return fetchJson(`${this.apiBaseUrl()}/retros`, {
@@ -263,23 +260,7 @@ const RetroApi = {
retrieveConfig() {
return fetchJson(`${this.apiBaseUrl()}/config`);
},
fetchCountryCode() {
if (window.country_code) {
return new Promise((resolve) => {
resolve([200, { country_code: window.country_code }])
});
} else {
return fetch(this.ipCheckerUrl())
.then((response) => {
if (response.status === 204) return [response.status, ''];
return Promise.all([response.status, response.json()]);
});
}
}
};
module.exports = RetroApi;
@@ -50,18 +50,12 @@ class HomePage extends React.Component {
Logger.info('onGoogleLoginFailure');
}
isInEU(countryCode) {
return ['AT', 'BE', 'BG', 'HR', 'CZ', 'CY', 'DK', 'EE', 'FI', 'FR', 'DE', 'EL', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'SK', 'SI', 'ES', 'SE', 'GB', 'UK'].includes(countryCode);
}
render() {
return (
<div className="home-page">
<div className="sticky-header">
<div className="row">
{
this.isInEU(this.props.countryCode) ? <HomeLegalBanner /> : null
}
<HomeLegalBanner />
</div>
<div className="row header-title">
<div className="show-for-medium small-12 columns">
@@ -101,7 +101,6 @@ class Router extends React.Component {
});
Actions.retrieveConfig()
Actions.getCountryCode();
}
componentWillReceiveProps(nextProps) {
@@ -177,7 +176,6 @@ class Router extends React.Component {
if(this.isUserLoggedIn()){
this.listRetros();
} else {
this.injectMockCountryCode();
this.setState({Page: HomePage});
}
};
@@ -201,14 +199,6 @@ class Router extends React.Component {
isUserLoggedIn() {
return localStorage.getItem('authToken');
};
injectMockCountryCode() {
let queryString = window.location.search;
if (queryString.includes("countryCode=")) {
let split = queryString.split("countryCode=");
window.country_code = split[1];
}
}
}
module.exports = Router;
@@ -286,20 +286,7 @@ const ApiDispatcher = {
this.dispatch({type: 'notFound'});
}
});
},
getCountryCode() {
Logger.info('getCountryCode');
return RetroApi.fetchCountryCode().then(([status, data]) => {
if (status >= 200 && status < 400) {
this.dispatch({type: 'setCountryCode', data: {
countryCode: data.country_code
}});
} else if (status === 404) {
this.dispatch({type: 'notFound'});
}
});
},
}
};
module.exports = ApiDispatcher;
@@ -42,26 +42,4 @@ describe('HomePage', () => {
expect('showHomePageAnalytics').toHaveBeenDispatched();
});
});
describe('when country code is in EU', () => {
beforeEach(() => {
const HomePage = require('../../../app/components/home_page');
ReactDOM.render(<HomePage countryCode="DE"/>, root);
});
it('shows the cookies banner', () => {
expect('.banner').toContainText('use of cookies');
});
});
describe('when country code is not in EU', () => {
beforeEach(() => {
const HomePage = require('../../../app/components/home_page');
ReactDOM.render(<HomePage countryCode="US"/>, root);
});
it('does not shows the cookies banner', () => {
expect('.banner').not.toExist();
});
});
});
@@ -1183,21 +1183,4 @@ describe('ApiDispatcher', () => {
MockPromises.tickAllTheWay();
});
});
describe('getCountryCode', () => {
beforeEach(() => {
subject.$store = new Cursor({}, cursorSpy);
subject.dispatch({type: 'getCountryCode', data: undefined});
});
it('makes an api GET to "https://freegeoip.net/json/"', () => {
expect('https://freegeoip.net/json/').toHaveBeenRequestedWith({
method: 'GET',
url: 'https://freegeoip.net/json/'
});
const request = jasmine.Ajax.requests.mostRecent();
request.succeed();
MockPromises.tickAllTheWay();
});
})
});

0 comments on commit dc357d4

Please sign in to comment.