aboutsummaryrefslogtreecommitdiffstats
path: root/spec/features/users/user_show_spec.rb
blob: ae3c259335c2b3557ae61df912648f61bd932ff5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'spec_helper'

include Warden::Test::Helpers
Warden.test_mode!

# Feature: User profile page
#   As a user
#   I want to visit my user profile page
#   So I can see my personal account data
feature 'User profile page', :devise do

  after(:each) do
    Warden.test_reset!
  end

  # Scenario: User sees own profile
  #   Given I am signed in
  #   When I visit the user profile page
  #   Then I see my own email address
  scenario 'user sees own profile' do
    user = FactoryGirl.create(:user)
    user.organisation.workbenches << create(:workbench)
    login_as(user, :scope => :user)
    visit organisation_user_path(user)
    # FIXME ref #819
    # expect(page).to have_content 'Mon Profil'
    expect(page).to have_content user.email
  end

  # Scenario: User cannot see another user's profile
  #   Given I am signed in
  #   When I visit another user's profile
  #   Then I see an 'access denied' message
  scenario "user cannot see another user's profile" do
    me = FactoryGirl.create(:user)
    me.organisation.workbenches << create(:workbench)
    other = FactoryGirl.create(:user, email: 'other@example.com', :organisation => me.organisation)
    login_as(me, :scope => :user)
    Capybara.current_session.driver.header 'Referer', authenticated_root_path
    visit organisation_user_path(other)
    expect(page).to have_content other.email
  end

end