Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-11-28 10:43:53 +0300
committerTimothy Andrew <mail@timothyandrew.net>2016-12-16 13:59:32 +0300
commitf14d423dc7c9ec2d97c83f0c8893661922df4360 (patch)
tree9d5000ac1ff01949e2084ef86ea75172aa8845ef /spec/features/profiles
parentfc7a5a3806c7c7317731ea305715fe0573b90d88 (diff)
Add a controller spec for personal access tokens.
Split the existing feature spec into both feature and controller specs. Feature specs assert on browser DOM, and controller specs assert on database state.
Diffstat (limited to 'spec/features/profiles')
-rw-r--r--spec/features/profiles/personal_access_tokens_spec.rb51
1 files changed, 11 insertions, 40 deletions
diff --git a/spec/features/profiles/personal_access_tokens_spec.rb b/spec/features/profiles/personal_access_tokens_spec.rb
index 0ffeeff0921..55a01057c83 100644
--- a/spec/features/profiles/personal_access_tokens_spec.rb
+++ b/spec/features/profiles/personal_access_tokens_spec.rb
@@ -27,54 +27,25 @@ describe 'Profile > Personal Access Tokens', feature: true, js: true do
describe "token creation" do
it "allows creation of a token" do
- visit profile_personal_access_tokens_path
- fill_in "Name", with: FFaker::Product.brand
-
- expect {click_on "Create Personal Access Token"}.to change { PersonalAccessToken.count }.by(1)
- expect(created_personal_access_token).to eq(PersonalAccessToken.last.token)
- expect(active_personal_access_tokens).to have_text(PersonalAccessToken.last.name)
- expect(active_personal_access_tokens).to have_text("Never")
- end
+ name = FFaker::Product.brand
- it "allows creation of a token with an expiry date" do
visit profile_personal_access_tokens_path
- fill_in "Name", with: FFaker::Product.brand
+ fill_in "Name", with: name
# Set date to 1st of next month
find_field("Expires at").trigger('focus')
find("a[title='Next']").click
click_on "1"
- expect {click_on "Create Personal Access Token"}.to change { PersonalAccessToken.count }.by(1)
- expect(created_personal_access_token).to eq(PersonalAccessToken.last.token)
- expect(active_personal_access_tokens).to have_text(PersonalAccessToken.last.name)
- expect(active_personal_access_tokens).to have_text(Date.today.next_month.at_beginning_of_month.to_s(:medium))
- end
-
- context "scopes" do
- it "allows creation of a token with scopes" do
- visit profile_personal_access_tokens_path
- fill_in "Name", with: FFaker::Product.brand
-
- check "api"
- check "read_user"
-
- expect {click_on "Create Personal Access Token"}.to change { PersonalAccessToken.count }.by(1)
- expect(created_personal_access_token).to eq(PersonalAccessToken.last.token)
- expect(PersonalAccessToken.last.scopes).to match_array(['api', 'read_user'])
- expect(active_personal_access_tokens).to have_text('api')
- expect(active_personal_access_tokens).to have_text('read_user')
- end
-
- it "allows creation of a token with no scopes" do
- visit profile_personal_access_tokens_path
- fill_in "Name", with: FFaker::Product.brand
+ # Scopes
+ check "api"
+ check "read_user"
- expect {click_on "Create Personal Access Token"}.to change { PersonalAccessToken.count }.by(1)
- expect(created_personal_access_token).to eq(PersonalAccessToken.last.token)
- expect(PersonalAccessToken.last.scopes).to eq([])
- expect(active_personal_access_tokens).to have_text('no scopes')
- end
+ click_on "Create Personal Access Token"
+ expect(active_personal_access_tokens).to have_text(name)
+ expect(active_personal_access_tokens).to have_text(Date.today.next_month.at_beginning_of_month.to_s(:medium))
+ expect(active_personal_access_tokens).to have_text('api')
+ expect(active_personal_access_tokens).to have_text('read_user')
end
context "when creation fails" do
@@ -111,7 +82,7 @@ describe 'Profile > Personal Access Tokens', feature: true, js: true do
disallow_personal_access_token_saves!
visit profile_personal_access_tokens_path
- expect { click_on "Revoke" }.not_to change { PersonalAccessToken.inactive.count }
+ click_on "Revoke"
expect(active_personal_access_tokens).to have_text(personal_access_token.name)
expect(page).to have_content("Could not revoke")
end