Skip to content

Instantly share code, notes, and snippets.

@andrewculver
Created February 24, 2020 18:10
Show Gist options
  • Save andrewculver/99bba8d96c65f37dc701b5f6cc4288a7 to your computer and use it in GitHub Desktop.
Save andrewculver/99bba8d96c65f37dc701b5f6cc4288a7 to your computer and use it in GitHub Desktop.
Example diff when adding attributes on a project that doesn't use trailing commas on multiline arrays and hashes.
diff --git a/app/controllers/account/sites_controller.rb b/app/controllers/account/sites_controller.rb
index 6f5936a0..5734b58b 100644
--- a/app/controllers/account/sites_controller.rb
+++ b/app/controllers/account/sites_controller.rb
@@ -64,9 +64,13 @@ class Account::SitesController < Account::ApplicationController
def site_params
params.require(:site).permit(
:name,
- :description
+ :description,
+ :keywords,
+ :copyright
)
end
end
diff --git a/app/controllers/api/v1/sites_controller.rb b/app/controllers/api/v1/sites_controller.rb
index 39222e34..85b6c1fe 100644
--- a/app/controllers/api/v1/sites_controller.rb
+++ b/app/controllers/api/v1/sites_controller.rb
@@ -49,9 +49,13 @@ class Api::V1::SitesController < Api::V1::AuthenticatedController
def site_params
params.require(:site).permit(
:name,
- :description
+ :description,
+ :keywords,
+ :copyright
)
end
end
diff --git a/app/serializers/api/v1/site_serializer.rb b/app/serializers/api/v1/site_serializer.rb
index 15f4fd81..70d18832 100644
--- a/app/serializers/api/v1/site_serializer.rb
+++ b/app/serializers/api/v1/site_serializer.rb
@@ -2,5 +2,7 @@ class Api::V1::SiteSerializer < ActiveModel::Serializer
attributes :id,
:team_id,
:name,
- :description
+ :description,
+ :keywords,
+ :copyright
end
diff --git a/app/views/account/sites/_site.json.jbuilder b/app/views/account/sites/_site.json.jbuilder
index 1f3a284b..5fd059f1 100644
--- a/app/views/account/sites/_site.json.jbuilder
+++ b/app/views/account/sites/_site.json.jbuilder
@@ -2,5 +2,7 @@ json.extract! site,
:id,
:team_id,
:name,
- :description
+ :description,
+ :keywords,
+ :copyright
json.url account_site_url(site, format: :json)
diff --git a/test/controllers/account/sites_controller_test.rb b/test/controllers/account/sites_controller_test.rb
index 4391af14..0c796d26 100644
--- a/test/controllers/account/sites_controller_test.rb
+++ b/test/controllers/account/sites_controller_test.rb
@@ -26,7 +26,9 @@ class Account::SitesControllerTest < ActionDispatch::IntegrationTest
post url_for([:account, @team, :sites]), params: {
site: {
name: @site.name,
- description: @site.description
+ description: @site.description,
+ keywords: @site.keywords,
+ copyright: @site.copyright
}
}
end
@@ -48,7 +50,9 @@ class Account::SitesControllerTest < ActionDispatch::IntegrationTest
patch url_for([:account, @site]), params: {
site: {
name: @site.name,
- description: @site.description
+ description: @site.description,
+ keywords: @site.keywords,
+ copyright: @site.copyright
}
}
assert_redirected_to url_for([:account, @site])
diff --git a/test/controllers/api/v1/sites_controller_test.rb b/test/controllers/api/v1/sites_controller_test.rb
index ee2e2506..3ed74714 100644
--- a/test/controllers/api/v1/sites_controller_test.rb
+++ b/test/controllers/api/v1/sites_controller_test.rb
@@ -101,7 +100,9 @@ class Api::V1::SitesControllerTest < ActionDispatch::IntegrationTest
# post an attribute update to the api and ensure nothing is seriously broken.
put url_for([:api, :v1, @site]), params: {
site: {
name: 'Alternative String Value'
- description: 'Alternative String Value'
+ description: 'Alternative String Value',
+ keywords: 'Alternative String Value',
+ copyright: 'Alternative String Value'
}
}, headers: auth_header
assert_response :success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment