app_regenerate_api_key_spec.rb
3.08 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
require 'acceptance/acceptance_helper'
feature "Regeneration api_Key" do
let(:app) { Fabricate(:app) }
let(:admin) { Fabricate(:admin) }
let(:user) {
Fabricate(:user_watcher, :app => app).user
}
before do
app && admin
end
scenario "an admin change api_key" do
visit '/'
log_in admin
click_link app.name
click_link I18n.t('apps.show.edit')
expect {
click_link I18n.t('apps.fields.regenerate_api_key')
}.to change {
app.reload.api_key
}
click_link I18n.t('shared.navigation.apps')
click_link I18n.t('apps.index.new_app')
expect(page).to_not have_button I18n.t('apps.fields.regenerate_api_key')
end
scenario "a user cannot access to edit page" do
visit '/'
log_in user
click_link app.name if page.current_url != app_url(app)
expect(page).to_not have_button I18n.t('apps.show.edit')
end
end
feature "Create an application" do
let(:admin) { Fabricate(:admin) }
let(:user) {
Fabricate(:user_watcher, :app => app).user
}
before do
admin
end
scenario "create an apps without issue tracker and edit it" do
visit '/'
log_in admin
click_on I18n.t('apps.index.new_app')
fill_in 'app_name', :with => 'My new app'
click_on I18n.t('apps.new.add_app')
page.has_content?(I18n.t('controllers.apps.flash.create.success'))
expect(App.where(:name => 'My new app').count).to eq 1
expect(App.where(:name => 'My new app 2').count).to eq 0
click_on I18n.t('shared.navigation.apps')
click_on 'My new app'
click_link I18n.t('apps.show.edit')
fill_in 'app_name', :with => 'My new app 2'
click_on I18n.t('apps.edit.update')
page.has_content?(I18n.t('controllers.apps.flash.update.success'))
expect(App.where(:name => 'My new app').count).to eq 0
expect(App.where(:name => 'My new app 2').count).to eq 1
end
scenario "create an apps with issue tracker and edit it", :js => true do
visit '/'
log_in admin
click_on I18n.t('apps.index.new_app')
fill_in 'app_name', :with => 'My new app'
find('.label_radio.github').click
fill_in 'app_github_repo', with: 'foo/bar'
within ".github.tracker_params" do
fill_in 'app_issue_tracker_attributes_options_username', :with => 'token'
fill_in 'app_issue_tracker_attributes_options_password', :with => 'pass'
end
click_on I18n.t('apps.new.add_app')
expect(page.has_content?(I18n.t('controllers.apps.flash.create.success'))).to eql true
app = App.where(:name => 'My new app').first
expect(app.issue_tracker.type_tracker).to eql 'github'
expect(app.issue_tracker.options['username']).to eql 'token'
expect(app.issue_tracker.options['password']).to eql 'pass'
click_on I18n.t('shared.navigation.apps')
click_on 'My new app'
click_link I18n.t('apps.show.edit')
find('.issue_tracker .label_radio.none').click
click_on I18n.t('apps.edit.update')
expect(page.has_content?(I18n.t('controllers.apps.flash.update.success'))).to eql true
app = App.where(:name => 'My new app').first
expect(app.issue_tracker.tracker).to be_a ErrbitPlugin::NoneIssueTracker
end
end