From 01acc846794f0de21a0eac58b6e5317553d5dac2 Mon Sep 17 00:00:00 2001 From: kikito Date: Thu, 10 Sep 2015 17:41:15 +0200 Subject: [PATCH] Adds failing tests for welcome spec --- spec/features/welcome_spec.rb | 45 ++++++++++++++++++++++++++++++++++ spec/support/common_actions.rb | 10 ++++++++ 2 files changed, 55 insertions(+) create mode 100644 spec/features/welcome_spec.rb diff --git a/spec/features/welcome_spec.rb b/spec/features/welcome_spec.rb new file mode 100644 index 000000000..2635ef0df --- /dev/null +++ b/spec/features/welcome_spec.rb @@ -0,0 +1,45 @@ +require 'rails_helper' + +feature "Welcome screen" do + + scenario 'a regular users sees it the first time he logs in' do + user = create(:user) + + login_through_form_as(user) + + expect(current_path).to eq(welcome_path) + end + + scenario 'it is not shown more than once' do + user = create(:user, sign_in_count: 2) + + login_through_form_as(user) + + expect(current_path).to eq(root_path) + end + + scenario 'is not shown to organizations' do + organization = create(:organization) + + login_through_form_as(organization.user) + + expect(current_path).to eq(root_path) + end + + scenario 'it is not shown to level-2 users' do + user = create(:user, residence_verified_at: Time.now, confirmed_phone: "123") + + login_through_form_as(user) + + expect(current_path).to eq(root_path) + end + + scenario 'it is not shown to level-3 users' do + user = create(:user, verified_at: Time.now) + + login_through_form_as(user) + + expect(current_path).to eq(root_path) + end + +end diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index c1d382b4e..61974864d 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -14,6 +14,16 @@ module CommonActions click_button 'Sign up' end + def login_through_form_as(user) + visit root_path + click_link 'Log in' + + fill_in 'user_email', with: user.email + fill_in 'user_password', with: user.password + + click_button 'Log in' + end + def confirm_email expect(page).to have_content "A message with a confirmation link has been sent to your email address."