diff --git a/.rubocop_manual_todo.yml b/.rubocop_manual_todo.yml index 739a06e862c..24ceb075023 100644 --- a/.rubocop_manual_todo.yml +++ b/.rubocop_manual_todo.yml @@ -300,8 +300,6 @@ Rails/SaveBang: - 'spec/models/generic_commit_status_spec.rb' - 'spec/models/grafana_integration_spec.rb' - 'spec/models/group_spec.rb' - - 'spec/models/hooks/system_hook_spec.rb' - - 'spec/models/hooks/web_hook_spec.rb' - 'spec/models/identity_spec.rb' - 'spec/models/issue/metrics_spec.rb' - 'spec/models/issue_spec.rb' diff --git a/changelogs/unreleased/issue-220040-fix-rails-savebang-hooks-models.yml b/changelogs/unreleased/issue-220040-fix-rails-savebang-hooks-models.yml new file mode 100644 index 00000000000..d8a73f40114 --- /dev/null +++ b/changelogs/unreleased/issue-220040-fix-rails-savebang-hooks-models.yml @@ -0,0 +1,5 @@ +--- +title: Fix Rails/SaveBang Rubocop offenses for hooks module +merge_request: 57918 +author: Huzaifa Iftikhar @huzaifaiftikhar +type: fixed diff --git a/doc/development/geo/framework.md b/doc/development/geo/framework.md index 055b9ce4ad6..9a8b94bdf64 100644 --- a/doc/development/geo/framework.md +++ b/doc/development/geo/framework.md @@ -285,7 +285,7 @@ For example, to add support for files referenced by a `Widget` model with a t.integer :verification_state, default: 0, null: false, limit: 2 t.integer :retry_count, default: 0, limit: 2 t.integer :verification_retry_count, default: 0, limit: 2 - t.boolean :checksum_mismatch + t.boolean :checksum_mismatch, default: false, null: false t.binary :verification_checksum t.binary :verification_checksum_mismatched t.string :verification_failure, limit: 255 diff --git a/spec/models/hooks/system_hook_spec.rb b/spec/models/hooks/system_hook_spec.rb index e56d08c1847..02e630cbf27 100644 --- a/spec/models/hooks/system_hook_spec.rb +++ b/spec/models/hooks/system_hook_spec.rb @@ -56,7 +56,7 @@ RSpec.describe SystemHook do end it "user_destroy hook" do - user.destroy + user.destroy! expect(WebMock).to have_requested(:post, system_hook.url).with( body: /user_destroy/, @@ -102,7 +102,7 @@ RSpec.describe SystemHook do end it 'group destroy hook' do - group.destroy + group.destroy! expect(WebMock).to have_requested(:post, system_hook.url).with( body: /group_destroy/, diff --git a/spec/models/hooks/web_hook_spec.rb b/spec/models/hooks/web_hook_spec.rb index 3fc1ad6eb0d..413e69fb071 100644 --- a/spec/models/hooks/web_hook_spec.rb +++ b/spec/models/hooks/web_hook_spec.rb @@ -26,7 +26,7 @@ RSpec.describe WebHook do it 'strips :url before saving it' do hook.url = ' https://example.com ' - hook.save + hook.save! expect(hook.url).to eq('https://example.com') end @@ -45,14 +45,14 @@ RSpec.describe WebHook do it 'gets rid of whitespace' do hook.push_events_branch_filter = ' branch ' - hook.save + hook.save! expect(hook.push_events_branch_filter).to eq('branch') end it 'stores whitespace only as empty' do hook.push_events_branch_filter = ' ' - hook.save + hook.save! expect(hook.push_events_branch_filter).to eq('') end @@ -91,7 +91,7 @@ RSpec.describe WebHook do web_hook = create(:project_hook) create_list(:web_hook_log, 3, web_hook: web_hook) - expect { web_hook.destroy }.to change(web_hook.web_hook_logs, :count).by(-3) + expect { web_hook.destroy! }.to change(web_hook.web_hook_logs, :count).by(-3) end end end