Skip to content

Commit

Permalink
[48619] Fixed unit tests for new access token
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Pfohl committed Jun 26, 2024
1 parent b374622 commit 99fb6aa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
18 changes: 9 additions & 9 deletions spec/controllers/my_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@
it "creates a key" do
expect(user.api_tokens).to be_empty

post :generate_api_key
post :generate_api_key, params: { token_api: { token_name: "One heck of a token" } }
new_token = user.reload.api_tokens.last
expect(new_token).to be_present

Expand All @@ -317,12 +317,12 @@
end

context "with existing key" do
let!(:key) { Token::API.create user: }
let!(:key) { Token::API.create(user:, data: { name: "One heck of a token" }) }

it "must add the new key" do
expect(user.reload.api_tokens.last).to eq(key)

post :generate_api_key
post :generate_api_key, params: { token_api: { token_name: "Two heck of a token" } }

new_token = user.reload.api_tokens.last
expect(new_token).not_to eq(key)
Expand Down Expand Up @@ -353,18 +353,18 @@

it "revoke specific ical tokens" do
expect(user.ical_tokens).to contain_exactly(
ical_token_for_query, another_ical_token_for_query, ical_token_for_another_query
)
ical_token_for_query, another_ical_token_for_query, ical_token_for_another_query

Check notice on line 356 in spec/controllers/my_controller_spec.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] spec/controllers/my_controller_spec.rb#L356 <Layout/FirstArgumentIndentation>

Indent the first argument one step more than the start of the previous line.
Raw output
spec/controllers/my_controller_spec.rb:356:41: C: Layout/FirstArgumentIndentation: Indent the first argument one step more than the start of the previous line.
)

delete :revoke_ical_token, params: { id: another_ical_token_for_query.id }

expect(user.ical_tokens.reload).to contain_exactly(
ical_token_for_query, ical_token_for_another_query
)
ical_token_for_query, ical_token_for_another_query

Check notice on line 362 in spec/controllers/my_controller_spec.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] spec/controllers/my_controller_spec.rb#L362 <Layout/FirstArgumentIndentation>

Indent the first argument one step more than the start of the previous line.
Raw output
spec/controllers/my_controller_spec.rb:362:48: C: Layout/FirstArgumentIndentation: Indent the first argument one step more than the start of the previous line.
)

expect(user.ical_tokens.reload).not_to contain_exactly(
ical_token_for_another_query
)
ical_token_for_another_query

Check notice on line 366 in spec/controllers/my_controller_spec.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] spec/controllers/my_controller_spec.rb#L366 <Layout/FirstArgumentIndentation>

Indent the first argument one step more than the start of the previous line.
Raw output
spec/controllers/my_controller_spec.rb:366:52: C: Layout/FirstArgumentIndentation: Indent the first argument one step more than the start of the previous line.
)

expect(flash[:info]).to be_present
expect(flash[:error]).not_to be_present
Expand Down
8 changes: 8 additions & 0 deletions spec/factories/token_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@

factory :api_token, class: "::Token::API" do
user

transient do
name { "Default Token Name" }
end

after(:build) do |token, evaluator|
token.data = { name: evaluator.name }
end
end

factory :rss_token, class: "::Token::RSS" do
Expand Down

0 comments on commit 99fb6aa

Please sign in to comment.