diff --git a/.rubocop.yml b/.rubocop.yml index 8281ab3b6..b1c9d5061 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -33,6 +33,9 @@ RSpec: Layout/ClassStructure: Enabled: true +Layout/LineLength: + Max: 100 + Metrics: Enabled: true @@ -41,9 +44,6 @@ Metrics/BlockLength: - 'spec/**/*.rb' - 'Guardfile' -Metrics/LineLength: - Max: 100 - Performance/CaseWhenSplat: Enabled: true diff --git a/app/controllers/edit_controller.rb b/app/controllers/edit_controller.rb index c8f4d42db..32844d963 100644 --- a/app/controllers/edit_controller.rb +++ b/app/controllers/edit_controller.rb @@ -164,16 +164,15 @@ def update_branch(repo, name, sha) end def open_pr(head, base, title, description) - pr = github.create_pull_request( - original_repo_path, base, head, title, description, - labels: ["groupthink::proposal"] - ) + pr = github.create_pull_request(original_repo_path, base, head, title, description) Proposal.find_or_create_by!( number: pr.number, opened_at: Time.zone.now, title: title, proposer: @current_user ) + # Set PR label directly using admin as other users might not be able to + Octokit.add_issue_labels(original_repo_path, pr.number, [PROPOSAL_LABEL]) end def commit_file(repo, name, content, message, base_sha, branch_name) diff --git a/app/controllers/ideas_controller.rb b/app/controllers/ideas_controller.rb index 9bf3b0267..cf2b9658c 100644 --- a/app/controllers/ideas_controller.rb +++ b/app/controllers/ideas_controller.rb @@ -5,7 +5,7 @@ # class IdeasController < ApplicationController def index - @ideas = Octokit.issues(ENV.fetch("GITHUB_REPO"), labels: "groupthink::idea") + @ideas = Octokit.issues(ENV.fetch("GITHUB_REPO"), labels: IDEA_LABEL) end def show diff --git a/app/views/ideas/index.html.erb b/app/views/ideas/index.html.erb index 2dad7a776..3fdbb9485 100644 --- a/app/views/ideas/index.html.erb +++ b/app/views/ideas/index.html.erb @@ -1,5 +1,5 @@
- + <%= fa_icon 'plus' %> Suggest a new idea diff --git a/config/initializers/octokit.rb b/config/initializers/octokit.rb index 94fef7094..5dfee9489 100644 --- a/config/initializers/octokit.rb +++ b/config/initializers/octokit.rb @@ -13,6 +13,9 @@ def create_label_if_missing(label:, colour:, description:) Octokit.add_label(ENV.fetch("GITHUB_REPO"), label, colour, description: description) end +IDEA_LABEL = "groupthink::idea" +PROPOSAL_LABEL = "groupthink::proposal" + unless Rails.env.test? # Configure GitHub webhook automatically begin @@ -44,6 +47,6 @@ def create_label_if_missing(label:, colour:, description:) } Octokit.edit_repository(ENV.fetch("GITHUB_REPO"), repo_options) # Set up labels - create_label_if_missing(label: "groupthink::proposal", colour: "d4c5f9", description: "Proposals to be voted on in Groupthink") - create_label_if_missing(label: "groupthink::idea", colour: "fbca04", description: "Ideas for future proposals") + create_label_if_missing(label: PROPOSAL_LABEL, colour: "d4c5f9", description: "Proposals to be voted on in Groupthink") + create_label_if_missing(label: IDEA_LABEL, colour: "fbca04", description: "Ideas for future proposals") end