Skip to content

Commit

Permalink
[rubocop] update to 0.49
Browse files Browse the repository at this point in the history
  • Loading branch information
dunn authored and jcoyne committed Jun 23, 2017
1 parent 3cd157d commit 72b5992
Show file tree
Hide file tree
Showing 20 changed files with 60 additions and 47 deletions.
38 changes: 23 additions & 15 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
inherit_from: .rubocop_todo.yml
require: rubocop-rspec
inherit_from: .rubocop_fixme.yml

AllCops:
TargetRubyVersion: 2.1
Expand All @@ -16,6 +17,9 @@ AllCops:
Bundler/DuplicatedGem: # This doesn't work with engine_cart
Enabled: false

Layout/IndentationConsistency:
EnforcedStyle: rails

Lint/ImplicitStringConcatenation:
Exclude:
- 'lib/generators/hyrax/**/*'
Expand Down Expand Up @@ -48,9 +52,6 @@ Metrics/MethodLength:
Style/AsciiComments:
Enabled: false

Style/IndentationConsistency:
EnforcedStyle: rails

Style/CollectionMethods:
PreferredMethods:
collect: 'map'
Expand Down Expand Up @@ -99,25 +100,32 @@ Style/ZeroLengthPredicate:
Rails:
Enabled: true

Rails/ApplicationJob:
Enabled: false

Rails/ApplicationRecord:
Enabled: false

Rails/DynamicFindBy:
Enabled: false

Rails/FilePath:
Exclude:
- 'spec/abilities/**/*'

Rails/OutputSafety:
Exclude:
- 'spec/views/hyrax/my/works/_list_works.html.erb_spec.rb'
- 'app/helpers/hyrax/hyrax_helper_behavior.rb'
- 'app/helpers/hyrax/collections_helper.rb'
- 'app/helpers/hyrax/content_block_helper_behavior.rb'
- 'app/builders/hyrax/form_builder.rb'
- 'app/helpers/hyrax/citations_behaviors/formatters/apa_formatter.rb'
- 'app/helpers/hyrax/citations_behaviors/formatters/chicago_formatter.rb'
- 'app/helpers/hyrax/citations_behaviors/formatters/mla_formatter.rb'
- 'app/helpers/hyrax/collections_helper.rb'
- 'app/helpers/hyrax/content_block_helper_behavior.rb'
- 'app/helpers/hyrax/hyrax_helper_behavior.rb'
- 'app/presenters/hyrax/fixity_status_presenter.rb'
- 'app/presenters/hyrax/presents_attributes.rb'
- 'app/renderers/hyrax/renderers/attribute_renderer.rb'

Rails/DynamicFindBy:
Enabled: false

Rails/FilePath:
Exclude:
- 'spec/abilities/**/*'
- 'spec/views/hyrax/my/works/_list_works.html.erb_spec.rb'

RSpec/DescribeClass:
Exclude:
Expand Down
11 changes: 8 additions & 3 deletions .rubocop_todo.yml → .rubocop_fixme.yml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Metrics/MethodLength:
Exclude:
- 'app/controllers/concerns/hyrax/api.rb'
- 'app/controllers/concerns/hyrax/controller.rb'
- 'app/controllers/hyrax/my_controller.rb'
- 'app/controllers/concerns/hyrax/works_controller_behavior.rb'
- 'app/controllers/hyrax/my_controller.rb'
- 'app/indexers/hyrax/file_set_indexer.rb'
- 'app/inputs/multi_value_select_input.rb'
- 'app/models/concerns/hyrax/solr_document/export.rb'
Expand All @@ -47,6 +47,11 @@ Metrics/MethodLength:
- 'lib/hyrax/rails/routes.rb'
- 'spec/support/**/*'

# TODO: remove when https://github.com/bbatsov/rubocop/issues/4539 is fixed
Style/FormatStringToken:
Exclude:
- 'config/routes.rb'

Style/LineEndConcatenation:
Exclude:
- 'spec/test_app_templates/lib/generators/**/*'
Expand Down Expand Up @@ -143,10 +148,10 @@ RSpec/AnyInstance:
- 'spec/jobs/content_new_version_event_job_spec.rb'
- 'spec/jobs/content_depositor_change_event_job_spec.rb'
- 'spec/jobs/content_deposit_event_job_spec.rb'
- 'spec/lib/hyrax/arkivo/create_subscription_job_spec.rb'
- 'spec/lib/hyrax/arkivo/actor_spec.rb'
- 'spec/presenters/hyrax/work_usage_spec.rb'
- 'spec/lib/hyrax/arkivo/create_subscription_job_spec.rb'
- 'spec/presenters/hyrax/file_usage_spec.rb'
- 'spec/presenters/hyrax/work_usage_spec.rb'
- 'spec/services/hyrax/repository_fixity_check_service_spec.rb'
- 'spec/services/hyrax/workflow/permission_generator_spec.rb'
- 'spec/services/hyrax/workflow/sipity_actions_generator_spec.rb'
Expand Down
Empty file modified Rakefile
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion hyrax.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ EOF
spec.add_development_dependency "factory_girl_rails", '~> 4.4'
spec.add_development_dependency "equivalent-xml", '~> 0.5'
spec.add_development_dependency "jasmine", '~> 2.3'
spec.add_development_dependency 'rubocop', '~> 0.48.1'
spec.add_development_dependency 'rubocop', '~> 0.49.1'
spec.add_development_dependency 'rubocop-rspec', '~> 1.10.0'
spec.add_development_dependency 'shoulda-matchers', '~> 3.1'
spec.add_development_dependency 'rails-controller-testing', '~> 0'
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/hyrax/homepage_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@
allow(controller).to receive(:repository).and_return(repository)
allow(controller).to receive(:search_results).and_return([nil, ['recent document']])
allow(controller.repository).to receive(:search).with(an_instance_of(Hyrax::CollectionSearchBuilder))
.and_return(collection_results)
.and_return(collection_results)
end

it "initializes the presenter with ability and a list of collections" do
expect(Hyrax::HomepagePresenter).to receive(:new).with(Ability,
["collection results"])
.and_return(presenter)
.and_return(presenter)
get :index
expect(response).to be_success
expect(assigns(:presenter)).to eq presenter
Expand Down
2 changes: 1 addition & 1 deletion spec/forms/hyrax/forms/permission_template_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def count_workflow_roles_for(user)
it "updates the visibility, release_period=now, release_date=today" do
expect { subject }
.to change { permission_template.reload.visibility }.from(nil).to('open')
.and change { permission_template.reload.release_period }.from(nil).to(Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_NO_DELAY)
.and change { permission_template.reload.release_period }.from(nil).to(Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_NO_DELAY)
expect(permission_template.release_date).to eq(today)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/hyrax/file_set_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

before do
allow(helper).to receive(:media_display_partial).with(file_set)
.and_return('hyrax/file_sets/media_display/image')
.and_return('hyrax/file_sets/media_display/image')
end

it "renders a partial" do
Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/content_deposit_event_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
expect do
described_class.perform_now(curation_concern, user)
end.to change { user.profile_events.length }.by(1)
.and change { curation_concern.events.length }.by(1)
.and change { curation_concern.events.length }.by(1)

expect(user.profile_events.first).to eq(event)
expect(curation_concern.events.first).to eq(event)
Expand Down
4 changes: 2 additions & 2 deletions spec/jobs/content_depositor_change_event_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
expect do
described_class.perform_now(generic_work, another_user)
end.to change { user.profile_events.length }.by(1)
.and change { another_user.events.length }.by(1)
.and change { generic_work.events.length }.by(1)
.and change { another_user.events.length }.by(1)
.and change { generic_work.events.length }.by(1)

expect(user.profile_events.first).to eq(event)
expect(another_user.events.first).to eq(event)
Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/content_new_version_event_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
expect do
described_class.perform_now(file_set, user)
end.to change { user.profile_events.length }.by(1)
.and change { file_set.events.length }.by(1)
.and change { file_set.events.length }.by(1)

expect(user.profile_events.first).to eq(event)
expect(file_set.events.first).to eq(event)
Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/content_restored_version_event_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
expect do
described_class.perform_now(file_set, user, 'content.0')
end.to change { user.profile_events.length }.by(1)
.and change { file_set.events.length }.by(1)
.and change { file_set.events.length }.by(1)

expect(user.profile_events.first).to eq(event)
expect(file_set.events.first).to eq(event)
Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/content_update_event_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
expect do
described_class.perform_now(curation_concern, user)
end.to change { user.profile_events.length }.by(1)
.and change { curation_concern.events.length }.by(1)
.and change { curation_concern.events.length }.by(1)

expect(user.profile_events.first).to eq(event)
expect(curation_concern.events.first).to eq(event)
Expand Down
4 changes: 2 additions & 2 deletions spec/jobs/file_set_attached_event_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
expect do
described_class.perform_now(file_set, user)
end.to change { user.profile_events.length }.by(1)
.and change { file_set.events.length }.by(1)
.and change { curation_concern.events.length }.by(1)
.and change { file_set.events.length }.by(1)
.and change { curation_concern.events.length }.by(1)

expect(user.profile_events.first).to eq(event)
expect(curation_concern.events.first).to eq(event)
Expand Down
2 changes: 1 addition & 1 deletion spec/services/hyrax/admin_set_create_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
expect do
expect(subject).to be true
end.to change { admin_set.persisted? }.from(false).to(true)
.and change { Sipity::WorkflowResponsibility.count }.by(12)
.and change { Sipity::WorkflowResponsibility.count }.by(12)
# 12 responsibilities because:
# * 2 agents (user + admin group), multiplied by
# * 2 available workflows, multiplied by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@

expect { described_class.send_notification(entity: entity, user: approver, comment: comment, recipients: recipients) }
.to change { depositor.mailbox.inbox.count }.by(1)
.and change { to_user.mailbox.inbox.count }.by(1)
.and change { cc_user.mailbox.inbox.count }.by(1)
.and change { to_user.mailbox.inbox.count }.by(1)
.and change { cc_user.mailbox.inbox.count }.by(1)
end
context 'without carbon-copied users' do
let(:recipients) { { 'to' => [to_user] } }
it 'sends a message to the to user(s)' do
expect(approver).to receive(:send_message).exactly(2).times.and_call_original
expect { described_class.send_notification(entity: entity, user: approver, comment: comment, recipients: recipients) }
.to change { depositor.mailbox.inbox.count }.by(1)
.and change { to_user.mailbox.inbox.count }.by(1)
.and change { to_user.mailbox.inbox.count }.by(1)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/services/hyrax/workflow/deposited_notification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@

expect { described_class.send_notification(entity: entity, user: approver, comment: comment, recipients: recipients) }
.to change { depositor.mailbox.inbox.count }.by(1)
.and change { to_user.mailbox.inbox.count }.by(1)
.and change { cc_user.mailbox.inbox.count }.by(1)
.and change { to_user.mailbox.inbox.count }.by(1)
.and change { cc_user.mailbox.inbox.count }.by(1)
end
context 'without carbon-copied users' do
let(:recipients) { { 'to' => [to_user] } }
it 'sends a message to the to user(s)' do
expect(approver).to receive(:send_message).exactly(2).times.and_call_original
expect { described_class.send_notification(entity: entity, user: approver, comment: comment, recipients: recipients) }
.to change { depositor.mailbox.inbox.count }.by(1)
.and change { to_user.mailbox.inbox.count }.by(1)
.and change { to_user.mailbox.inbox.count }.by(1)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/services/hyrax/workflow/notification_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ module Workflow
expect do
described_class.call(workflow: workflow, notification_configuration: notification_configuration)
end.to change { Sipity::Notification.count }.by(1)
.and change { Sipity::NotificationRecipient.count }.by(3)
.and change { workflow_action.notifiable_contexts.count }.by(1)
.and change { Sipity::NotificationRecipient.count }.by(3)
.and change { workflow_action.notifiable_contexts.count }.by(1)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@

expect { described_class.send_notification(entity: entity, user: depositor, comment: comment, recipients: recipients) }
.to change { depositor.mailbox.inbox.count }.by(1)
.and change { to_user.mailbox.inbox.count }.by(1)
.and change { cc_user.mailbox.inbox.count }.by(1)
.and change { to_user.mailbox.inbox.count }.by(1)
.and change { cc_user.mailbox.inbox.count }.by(1)
end
context 'without carbon-copied users' do
let(:recipients) { { 'to' => [to_user] } }
it 'sends a message to the to user(s)' do
expect(depositor).to receive(:send_message).exactly(2).times.and_call_original
expect { described_class.send_notification(entity: entity, user: depositor, comment: comment, recipients: recipients) }
.to change { depositor.mailbox.inbox.count }.by(1)
.and change { to_user.mailbox.inbox.count }.by(1)
.and change { to_user.mailbox.inbox.count }.by(1)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/services/hyrax/workflow/permission_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ module Workflow
expect do
described_class.call(agents: user, roles: role.name, workflow: workflow)
end.to change { Sipity::WorkflowRole.count }.by(1)
.and change { Sipity::WorkflowResponsibility.count }.by(1)
.and change { Sipity::WorkflowResponsibility.count }.by(1)
end

it 'will grant entity responsiblity to agent as the given role' do
expect do
described_class.call(agents: user, roles: role.name, workflow: workflow, entity: entity)
end.to change { Sipity::WorkflowRole.count }.by(1)
.and change { Sipity::EntitySpecificResponsibility.count }.by(1)
.and change { Sipity::WorkflowResponsibility.count }.by(0)
.and change { Sipity::EntitySpecificResponsibility.count }.by(1)
.and change { Sipity::WorkflowResponsibility.count }.by(0)
end

it 'will be idempotent' do
Expand Down
2 changes: 1 addition & 1 deletion spec/services/hyrax/workflow/workflow_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
expect do
subject
end.to change { Sipity::Entity.count }.by(1)
.and change { Sipity::EntitySpecificResponsibility.count }.by(1)
.and change { Sipity::EntitySpecificResponsibility.count }.by(1)
end.not_to change { Sipity::WorkflowResponsibility.count }
end
end
Expand Down

0 comments on commit 72b5992

Please sign in to comment.