diff --git a/app/controllers/admin/enterprise_groups_controller.rb b/app/controllers/admin/enterprise_groups_controller.rb index cb3ac80935..022b2f7d61 100644 --- a/app/controllers/admin/enterprise_groups_controller.rb +++ b/app/controllers/admin/enterprise_groups_controller.rb @@ -9,7 +9,7 @@ module Admin def move_up EnterpriseGroup.with_isolation_level_serializable do - @enterprise_group = EnterpriseGroup.find_by_permalink params[:enterprise_group_id] + @enterprise_group = find_resource @enterprise_group.move_higher end redirect_to main_app.admin_enterprise_groups_path @@ -17,7 +17,7 @@ module Admin def move_down EnterpriseGroup.with_isolation_level_serializable do - @enterprise_group = EnterpriseGroup.find_by_permalink params[:enterprise_group_id] + @enterprise_group = find_resource @enterprise_group.move_lower end redirect_to main_app.admin_enterprise_groups_path @@ -34,9 +34,11 @@ module Admin alias_method_chain :build_resource, :address # Overriding method on Spree's resource controller, - # so that resources are found using permalink + # so that resources are found using permalink. + # The ! version is important to raise a RecordNotFound error. def find_resource - EnterpriseGroup.find_by_permalink(params[:id]) + permalink = params[:id] || params[:enterprise_group_id] + EnterpriseGroup.find_by_permalink!(permalink) end private diff --git a/app/controllers/admin/producer_properties_controller.rb b/app/controllers/admin/producer_properties_controller.rb index 66656d9aa0..aca3e3f418 100644 --- a/app/controllers/admin/producer_properties_controller.rb +++ b/app/controllers/admin/producer_properties_controller.rb @@ -12,7 +12,7 @@ module Admin end def load_enterprise - @enterprise = Enterprise.find_by_permalink params[:enterprise_id] + @enterprise = Enterprise.find_by_permalink! params[:enterprise_id] end def load_properties diff --git a/script/ci/check_github_status.sh b/script/ci/check_github_status.sh new file mode 100755 index 0000000000..c4ce47c6fa --- /dev/null +++ b/script/ci/check_github_status.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e +source "`dirname $0`/includes.sh" + +OFN_COMMIT=$(get_ofn_commit) +if [ "$OFN_COMMIT" = 'OFN_COMMIT_NOT_FOUND' ]; then + OFN_COMMIT=$(git rev-parse $BUILDKITE_COMMIT) +fi + +GITHUB_REPO="$(echo $BUILDKITE_REPO | sed 's/git@github.com:\(.*\).git/\1/')" +GITHUB_API_URL="https://api.github.com/repos/$GITHUB_REPO/commits/$OFN_COMMIT/status" + +echo "--- Checking environment variables" +require_env_vars OFN_COMMIT BUILDKITE_REPO + +echo "--- Checking GitHub status" +echo "Visiting $GITHUB_API_URL" +curl -s "$GITHUB_API_URL" | head -n 2 | grep '^ *"state": "success",$'