Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

fixed rubocop issues outside of the calendar module introduced while working on this PR

Jonas Jabari1abf957c7870
diff --git a/app/models/token/ical.rb b/app/models/token/ical.rb
index 24331672b9b..3095960b450 100644
--- a/app/models/token/ical.rb
+++ b/app/models/token/ical.rb
@@ -28,7 +28,6 @@
module Token
class Ical < HashedToken
-
# Prevent deleting previous tokens
# Every time an ical url is generated, a new ical token will be generated for this url as well
# the existing ical tokens (and thus urls) should still be valid
@@ -36,6 +35,5 @@ module Token
def delete_previous_token
nil
end
-
end
end
diff --git a/app/policies/query_policy.rb b/app/policies/query_policy.rb
index 6430f86c3d1..7575b30dabb 100644
--- a/app/policies/query_policy.rb
+++ b/app/policies/query_policy.rb
@@ -120,7 +120,7 @@ class QueryPolicy < BasePolicy
@manage_public_queries_cache[query.project]
end
-
+
def share_via_ical_allowed?(query)
@share_via_ical_cache ||= Hash.new do |hash, project|
hash[project] = user.allowed_to?(:share_calendars, project, global: project.nil?)
diff --git a/lib/api/v3/queries/queries_api.rb b/lib/api/v3/queries/queries_api.rb
index 6e0444ba64a..6a0f3bf51d6 100644
--- a/lib/api/v3/queries/queries_api.rb
+++ b/lib/api/v3/queries/queries_api.rb
@@ -165,7 +165,7 @@ module API
# currently the generated URL points to controller action in calendar module
# correct approach? or should it be implemented as a API here?
- call = ::Calendar::GenerateIcalUrl.new().call(
+ call = ::Calendar::GenerateIcalUrl.new.call(
user: current_user,
query_id: @query.id,
project_id: @query.project_id
diff --git a/lib/api/v3/queries/query_representer.rb b/lib/api/v3/queries/query_representer.rb
index 45c7c5d7831..c12f33c3b6e 100644
--- a/lib/api/v3/queries/query_representer.rb
+++ b/lib/api/v3/queries/query_representer.rb
@@ -146,7 +146,7 @@ module API
method: :delete
}
end
-
+
link :shareCalendars do
next if represented.new_record? ||
!allowed_to?(:share_via_ical)
diff --git a/spec/controllers/my_controller_spec.rb b/spec/controllers/my_controller_spec.rb
index 602a416edfa..378f03262c2 100644
--- a/spec/controllers/my_controller_spec.rb
+++ b/spec/controllers/my_controller_spec.rb
@@ -315,11 +315,11 @@ describe MyController do
# in this context all ical tokens of a user should be reverted at once
# this invalidates all previously generated ical urls, which is the intention
context 'with existing keys' do
- let!(:key_1) { Token::Ical.create user: }
- let!(:key_2) { Token::Ical.create user: }
+ let!(:key1) { Token::Ical.create user: }
+ let!(:key2) { Token::Ical.create user: }
it 'revokes all existing keys' do
- expect(Token::Ical.where(user_id: user.id)).to contain_exactly(key_1, key_2)
+ expect(Token::Ical.where(user_id: user.id)).to contain_exactly(key1, key2)
post :revoke_all_ical_tokens
diff --git a/spec/features/users/my_spec.rb b/spec/features/users/my_spec.rb
index 24f3d1d2c2e..188ce0c5d88 100644
--- a/spec/features/users/my_spec.rb
+++ b/spec/features/users/my_spec.rb
@@ -154,32 +154,33 @@ describe 'my',
it 'in Access Tokens they can see if Ical tokens exists' do
visit my_access_token_path
expect(page).not_to have_content 'iCalendar'
-
- new_ical_token = Token::Ical.create user: user
+
+ new_ical_token = Token::Ical.create(user:)
visit my_access_token_path
expect(page).to have_content 'iCalendar'
within(:xpath, "//tr[contains(.,'iCalendar')]") do
- expect(page).to have_content "#{::I18n.l(new_ical_token.created_at, format: :time)} (latest)"
+ expect(page).to have_content "#{I18n.l(new_ical_token.created_at, format: :time)} (latest)"
end
- Timecop.travel(1.minutes.from_now) do
- another_new_ical_token = Token::Ical.create user: user
+ Timecop.travel(1.minute.from_now) do
+ another_new_ical_token = Token::Ical.create(user:)
visit my_access_token_path
expect(page).to have_content 'iCalendar'
within(:xpath, "//tr[contains(.,'iCalendar')]") do
- expect(page).not_to have_content "#{::I18n.l(new_ical_token.created_at, format: :time)} (latest)"
- expect(page).to have_content "#{::I18n.l(another_new_ical_token.created_at, format: :time)} (latest)"
+ expect(page).not_to have_content "#{I18n.l(new_ical_token.created_at, format: :time)} (latest)"
+ expect(page).to have_content "#{I18n.l(another_new_ical_token.created_at, format: :time)} (latest)"
end
end
end
- it 'in Access Tokens they can revoke all existing Ical tokens' do
- new_ical_token_1 = Token::Ical.create user: user
- new_ical_token_2 = Token::Ical.create user: user
+ it 'in Access Tokens they can revoke all existing Ical tokens' do
+ 2.times do
+ Token::Ical.create(user:)
+ end
visit my_access_token_path
within(:xpath, "//tr[contains(.,'iCalendar')]") do
@@ -194,6 +195,5 @@ describe 'my',
expect(Token::Ical.where(user_id: user.id).count).to eq 0
end
-
end
end
diff --git a/spec/models/token/ical_token_spec.rb b/spec/models/token/ical_token_spec.rb
index 444e488633f..a6b47a1814d 100644
--- a/spec/models/token/ical_token_spec.rb
+++ b/spec/models/token/ical_token_spec.rb
@@ -34,9 +34,8 @@ describe Token::Ical do
subject { described_class.new user: }
describe 'behaves like Token::HashedToken' do
-
it 'inherits from Token::HashedToken' do
- expect(described_class).to be < Token::HashedToken
+ expect(described_class).to be < Token::HashedToken
end
# following code is copy pasted from hashed_token_spec
@@ -70,27 +69,26 @@ describe Token::Ical do
end
it 'finds using the plaintext value' do
+ # rubocop:disable Rails/DynamicFindBy
expect(described_class.find_by_plaintext_value(subject.plain_value)).to eq subject
expect(described_class.find_by_plaintext_value('foobar')).to be_nil
+ # rubocop:enable Rails/DynamicFindBy
end
end
-
end
describe 'in contrast to HashedToken' do
-
it 'a user can have N ical tokens' do
# Every time an ical url is generated, a new ical token will be generated for this url as well
# the existing ical tokens (and thus urls) should still be valid
# until the user decides to revert all existing ical tokens (and urls)
# therefore a user needs to be allowed to have N ical token
- ical_token_1 = described_class.create user: user
- ical_token_2 = described_class.create user: user
+ ical_token1 = described_class.create(user:)
+ ical_token2 = described_class.create(user:)
- expect(Token::Ical.where(user_id: user.id)).to contain_exactly(
- ical_token_1, ical_token_2
+ expect(described_class.where(user_id: user.id)).to contain_exactly(
+ ical_token1, ical_token2
)
end
-
end
end