Skip to content

Instantly share code, notes, and snippets.

@andrewculver
Last active February 24, 2020 18:41
Show Gist options
  • Save andrewculver/382c291235d8924a2b61f3344bf0a78a to your computer and use it in GitHub Desktop.
Save andrewculver/382c291235d8924a2b61f3344bf0a78a to your computer and use it in GitHub Desktop.
Example diff when adding attributes on a project that uses trailing commas on multiline arrays and hashes.
diff --git a/app/controllers/account/sites_controller.rb b/app/controllers/account/sites_controller.rb
index c99a3877..318e7c67 100644
--- a/app/controllers/account/sites_controller.rb
+++ b/app/controllers/account/sites_controller.rb
@@ -65,6 +65,8 @@ class Account::SitesController < Account::ApplicationController
params.require(:site).permit(
:name,
:description,
+ :keywords,
+ :copyright,
)
diff --git a/app/controllers/api/v1/sites_controller.rb b/app/controllers/api/v1/sites_controller.rb
index e9167a23..e8d13f36 100644
--- a/app/controllers/api/v1/sites_controller.rb
+++ b/app/controllers/api/v1/sites_controller.rb
@@ -50,6 +50,8 @@ class Api::V1::SitesController < Api::V1::AuthenticatedController
params.require(:site).permit(
:name,
:description,
+ :keywords,
+ :copyright,
)
diff --git a/app/serializers/api/v1/site_serializer.rb b/app/serializers/api/v1/site_serializer.rb
index b3fa4f25..5a42ecec 100644
--- a/app/serializers/api/v1/site_serializer.rb
+++ b/app/serializers/api/v1/site_serializer.rb
@@ -3,6 +3,8 @@ class Api::V1::SiteSerializer < ActiveModel::Serializer
:team_id,
:name,
:description,
+ :keywords,
+ :copyright,
diff --git a/app/views/account/sites/_site.json.jbuilder b/app/views/account/sites/_site.json.jbuilder
index a0f3f510..df3208f5 100644
--- a/app/views/account/sites/_site.json.jbuilder
+++ b/app/views/account/sites/_site.json.jbuilder
@@ -3,6 +3,8 @@ json.extract! site,
:team_id,
:name,
:description,
+ :keywords,
+ :copyright,
diff --git a/test/controllers/account/sites_controller_test.rb b/test/controllers/account/sites_controller_test.rb
index 8a8eb708..253773b6 100644
--- a/test/controllers/account/sites_controller_test.rb
+++ b/test/controllers/account/sites_controller_test.rb
@@ -27,6 +27,8 @@ class Account::SitesControllerTest < ActionDispatch::IntegrationTest
site: {
name: @site.name,
description: @site.description,
+ keywords: @site.keywords,
+ copyright: @site.copyright,
}
}
@@ -50,6 +52,8 @@ class Account::SitesControllerTest < ActionDispatch::IntegrationTest
site: {
name: @site.name,
description: @site.description,
+ keywords: @site.keywords,
+ copyright: @site.copyright,
}
}
diff --git a/test/controllers/api/v1/sites_controller_test.rb b/test/controllers/api/v1/sites_controller_test.rb
index 331d2831..4eb47917 100644
--- a/test/controllers/api/v1/sites_controller_test.rb
+++ b/test/controllers/api/v1/sites_controller_test.rb
@@ -102,6 +104,8 @@ class Api::V1::SitesControllerTest < ActionDispatch::IntegrationTest
put url_for([:api, :v1, @site]), params: {
site: {
name: 'Alternative String Value',
description: 'Alternative String Value',
+ keywords: 'Alternative String Value',
+ copyright: 'Alternative String Value',
}
}, headers: auth_header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment