OSDN Git Service

Fix 404 on project page for unauthenticated user
[wvm/gitlab.git] / features / steps / profile / profile.rb
1 class Profile < Spinach::FeatureSteps
2   include SharedAuthentication
3   include SharedPaths
4
5   step 'I should see my profile info' do
6     page.should have_content "Profile settings"
7   end
8
9   step 'I change my contact info' do
10     fill_in "user_skype", with: "testskype"
11     fill_in "user_linkedin", with: "testlinkedin"
12     fill_in "user_twitter", with: "testtwitter"
13     click_button "Save changes"
14     @user.reload
15   end
16
17   step 'I should see new contact info' do
18     @user.skype.should == 'testskype'
19     @user.linkedin.should == 'testlinkedin'
20     @user.twitter.should == 'testtwitter'
21   end
22
23   step 'I change my avatar' do
24     attach_file(:user_avatar, File.join(Rails.root, 'public', 'gitlab_logo.png'))
25     click_button "Save changes"
26     @user.reload
27   end
28
29   step 'I should see new avatar' do
30     @user.avatar.should be_instance_of AttachmentUploader
31     @user.avatar.url.should == "/uploads/user/avatar/#{ @user.id }/gitlab_logo.png"
32   end
33
34   step 'I should see the "Remove avatar" button' do
35     page.should have_link("Remove avatar")
36   end
37
38   step 'I have an avatar' do
39     attach_file(:user_avatar, File.join(Rails.root, 'public', 'gitlab_logo.png'))
40     click_button "Save changes"
41     @user.reload
42   end
43
44   step 'I remove my avatar' do
45     click_link "Remove avatar"
46     @user.reload
47   end
48
49   step 'I should see my gravatar' do
50     @user.avatar?.should be_false
51   end
52
53   step 'I should not see the "Remove avatar" button' do
54     page.should_not have_link("Remove avatar")
55   end
56
57   step 'I try change my password w/o old one' do
58     within '.update-password' do
59       fill_in "user_password", with: "22233344"
60       fill_in "user_password_confirmation", with: "22233344"
61       click_button "Save"
62     end
63   end
64
65   step 'I change my password' do
66     within '.update-password' do
67       fill_in "user_current_password", with: "12345678"
68       fill_in "user_password", with: "22233344"
69       fill_in "user_password_confirmation", with: "22233344"
70       click_button "Save"
71     end
72   end
73
74   step 'I unsuccessfully change my password' do
75     within '.update-password' do
76       fill_in "user_current_password", with: "12345678"
77       fill_in "user_password", with: "password"
78       fill_in "user_password_confirmation", with: "confirmation"
79       click_button "Save"
80     end
81   end
82
83   step "I should see a missing password error message" do
84     page.should have_content "You must provide a valid current password"
85   end
86
87   step "I should see a password error message" do
88     page.should have_content "Password doesn't match confirmation"
89   end
90
91   step 'I reset my token' do
92     within '.update-token' do
93       @old_token = @user.private_token
94       click_button "Reset"
95     end
96   end
97
98   step 'I should see new token' do
99     find("#token").value.should_not == @old_token
100     find("#token").value.should == @user.reload.private_token
101   end
102
103   step 'I have activity' do
104     create(:closed_issue_event, author: current_user)
105   end
106
107   step 'I should see my activity' do
108     page.should have_content "#{current_user.name} closed issue"
109   end
110
111   step "I change my application theme" do
112     within '.application-theme' do
113       choose "Violet"
114     end
115   end
116
117   step "I change my code preview theme" do
118     within '.code-preview-theme' do
119       choose "Solarized dark"
120     end
121   end
122
123   step "I should see the theme change immediately" do
124     page.should have_selector('body.ui_color')
125     page.should_not have_selector('body.ui_basic')
126   end
127
128   step "I should receive feedback that the changes were saved" do
129     page.should have_content("saved")
130   end
131
132   step 'my password is expired' do
133     current_user.update_attributes(password_expires_at: Time.now - 1.hour)
134   end
135
136   step "I am not an ldap user" do
137     current_user.update_attributes(extern_uid: nil,  provider: '')
138     current_user.ldap_user?.should be_false
139   end
140
141   step 'I redirected to expired password page' do
142     current_path.should == new_profile_password_path
143   end
144
145   step 'I submit new password' do
146     fill_in :user_password, with: '12345678'
147     fill_in :user_password_confirmation, with: '12345678'
148     click_button "Set new password"
149   end
150
151   step 'I redirected to sign in page' do
152     current_path.should == new_user_session_path
153   end
154
155   step 'I should be redirected to password page' do
156     current_path.should == edit_profile_password_path
157   end
158
159   step 'I should be redirected to account page' do
160     current_path.should == profile_account_path
161   end
162
163   step 'I click on my profile picture' do
164     click_link 'profile-pic'
165   end
166
167   step 'I should see my user page' do
168     page.should have_content "User Activity"
169
170     within '.navbar-gitlab' do
171       page.should have_content current_user.name
172     end
173   end
174 end