This commit is contained in:
Anitha Palanisamy 2017-02-08 18:38:34 +00:00 • committed by GitHub
commit 5c198a11aa
11 changed files with 215 additions and 18 deletions

View file

@ -20,6 +20,20 @@ FactoryGirl.define do
sequence(:username) { |n| "username#{n}" }
password 'changeme'
password_confirmation 'changeme'
trait :with_social_media_and_code_info do
googleplus { Faker::Internet.url('plus.google.com') }
linkedin {Faker::Internet.url('linkedin.com')}
website_url{Faker::Internet.url('example.com')}
gnu{Faker::Internet.url('gnu.io')}
twitter{Faker::Internet.url('twitter.com')}
github{Faker::Internet.url('github.com')}
gitlab{Faker::Internet.url('gitlab')}
savannah{Faker::Internet.url('savannah.gnu.org')}
diaspora{Faker::Internet.url('joindiaspora.com')}
gna{Faker::Internet.url('gna.com')}
end
confirmed_at { Time.now }
biography <<-EOS
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus enim

View file

@ -1,6 +1,39 @@
require 'spec_helper'
feature User do
let!(:user) {create(:user, :with_social_media_and_code_info)}
describe 'update user profile' do
scenario 'sucessfully', feature: true do
sign_in user
visit edit_user_path(user.id)
fill_in 'user_website_url', with: 'http://www.example1.com'
fill_in 'user_linkedin', with: 'http://www.linkedin.com/testosemuser1'
fill_in 'user_gnu', with: 'http://gnu.io/testosemuser1'
fill_in 'user_twitter', with: 'http://www.twitter.com/testosemuser1'
fill_in 'user_github', with: 'http://www.github.com/testosemuser1'
fill_in 'user_gitlab', with: 'http://www.gitlab.com/testosemuser1'
fill_in 'user_gna', with: 'http://www.gna.com/testosemuser1'
fill_in 'user_diaspora', with: 'http://joindiaspora.com/testosemuser1'
fill_in 'user_savannah', with: 'http://savannah.gnu.org/testosemuser1'
fill_in 'user_googleplus', with: 'http://plus.google.com/testosemurl1'
click_button 'Update'
expect(flash). to eq('User was successfully updated.')
user.reload
expect(user.website_url).to eq('http://www.example1.com')
expect(user.linkedin).to eq('http://www.linkedin.com/testosemuser1')
expect(user.gnu).to eq('http://gnu.io/testosemuser1')
expect(user.twitter).to eq('http://www.twitter.com/testosemuser1')
expect(user.github).to eq('http://www.github.com/testosemuser1')
expect(user.gitlab).to eq('http://www.gitlab.com/testosemuser1')
expect(user.googleplus).to eq('http://plus.google.com/testosemurl1')
expect(user.gna).to eq('http://www.gna.com/testosemuser1')
expect(user.diaspora).to eq('http://joindiaspora.com/testosemuser1')
expect(user.savannah).to eq('http://savannah.gnu.org/testosemuser1')
end
end
shared_examples 'admin ability' do
@ -9,4 +42,5 @@ feature User do
describe 'admin' do
it_behaves_like 'admin ability', :admin
end
end

View file

@ -9,8 +9,7 @@ describe User do
let(:cfp_role) { Role.find_by(name: 'cfp', resource: conference) }
let(:volunteers_coordinator_role) { Role.find_by(name: 'volunteers_coordinator', resource: conference) }
let(:organizer) { create(:user, role_ids: [organizer_role.id]) }
let(:user) { create(:user) }
let!(:user) {create(:user, :with_social_media_and_code_info)}
let(:event1) { create(:event, program: conference.program) }
let(:another_conference) { create(:conference) }
let(:event2) { create(:event, program: another_conference.program) }
@ -48,6 +47,34 @@ describe User do
end
end
describe 'url format validation' do
context 'with valid url' do
it { should allow_value('http://example.com').for(:website_url) }
it { should allow_value('http://linkedin.com').for(:linkedin) }
it { should allow_value('http://googleplus.com').for(:googleplus) }
it { should allow_value('http://gnu.com').for(:gnu) }
it { should allow_value('http://twitter.com').for(:twitter) }
it { should allow_value('http://github.com').for(:github) }
it { should allow_value('http://gitlab.com').for(:gitlab) }
it { should allow_value('http://joindiaspora.com').for(:diaspora) }
it { should allow_value('http://savannah.gnu.org').for(:savannah) }
it { should allow_value('https://linkedin.com').for(:gna) }
end
context 'with invalid url' do
it { should_not allow_value('example').for(:website_url) }
it { should_not allow_value('linkedin').for(:linkedin) }
it { should_not allow_value('googleplus').for(:googleplus) }
it { should_not allow_value('gnu').for(:gnu) }
it { should_not allow_value('@twitter').for(:twitter) }
it { should_not allow_value('@github').for(:github) }
it { should_not allow_value('@gitlab').for(:gitlab) }
it { should_not allow_value('diaspora').for(:diaspora) }
it { should_not allow_value('savannah').for(:savannah) }
it { should_not allow_value('gna').for(:gna) }
end
end
describe 'association' do
it { is_expected.to have_many(:openids) }
it { is_expected.to have_many(:event_users).dependent(:destroy) }