Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field generators #992

Merged
merged 4 commits into from
Oct 27, 2017
Merged

Conversation

ryanhertz
Copy link
Contributor

This addresses #486. Instead of copying the partials for all field types when no argument is given as suggested in the issue, I added support for passing "all" in place of the field name.

end

end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at block body end.


field_types.each do |field_type|
expected_contents = contents_for_field_template(field_type, :index)
contents = File.read(file("app/views/fields/#{field_type}/_index.html.erb"))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [86/80]


field_types.each do |field_type|
expected_contents = contents_for_field_template(field_type, :form)
contents = File.read(file("app/views/fields/#{field_type}/_form.html.erb"))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [85/80]


field_types.each do |field_type|
expected_contents = contents_for_field_template(field_type, :show)
contents = File.read(file("app/views/fields/#{field_type}/_show.html.erb"))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [85/80]


describe "administrate:views:field all" do

let(:field_types) { Dir.entries("app/views/fields").reject{ |name| name[0] == "."} }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space missing to the left of {.
Line is too long. [90/80]
Space missing inside }.

context "for an existing field type" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at block body beginning.

require "generators/administrate/views/field_generator"
require "support/generator_spec_helpers"

describe Administrate::Generators::Views::FieldGenerator, :generator do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at block body beginning.

template_file = "#{resource_path}/_#{partial_name}.html.erb"

copy_file(
template_file,
"app/views/fields/#{template_file}",
)
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at class body end.

resource_path = args.first.try(:underscore)

if resource_path == 'all'
field_types = Dir.entries(self.class.template_source_path).reject{ |name| name[0] == "."}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space missing to the left of {.
Line is too long. [101/80]
Space missing inside }.

copy_field_partial(:form)
resource_path = args.first.try(:underscore)

if resource_path == 'all'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

end
end
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at block body end.

field_types.each do |field_type|
expected_contents = contents_for_field_template(field_type, :index)
contents = File.read(
file("app/views/fields/#{field_type}/_index.html.erb")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put a comma after the last parameter of a multiline method call.

field_types.each do |field_type|
expected_contents = contents_for_field_template(field_type, :form)
contents = File.read(
file("app/views/fields/#{field_type}/_form.html.erb")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put a comma after the last parameter of a multiline method call.

field_types.each do |field_type|
expected_contents = contents_for_field_template(field_type, :show)
contents = File.read(
file("app/views/fields/#{field_type}/_show.html.erb")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put a comma after the last parameter of a multiline method call.

@@ -32,6 +34,52 @@
expect(contents).to eq(expected_contents)
end
end

describe "administrate:views:field all" do
let(:field_types) do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

end
end
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at block body end.

field_types.each do |field_type|
expected_contents = contents_for_field_template(field_type, :index)
contents = File.read(
file("app/views/fields/#{field_type}/_index.html.erb")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put a comma after the last parameter of a multiline method call.

field_types.each do |field_type|
expected_contents = contents_for_field_template(field_type, :form)
contents = File.read(
file("app/views/fields/#{field_type}/_form.html.erb")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put a comma after the last parameter of a multiline method call.

field_types.each do |field_type|
expected_contents = contents_for_field_template(field_type, :show)
contents = File.read(
file("app/views/fields/#{field_type}/_show.html.erb")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put a comma after the last parameter of a multiline method call.

@@ -32,6 +34,52 @@
expect(contents).to eq(expected_contents)
end
end

describe "administrate:views:field all" do
let(:field_types) do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

@thoughtbot thoughtbot deleted a comment from houndci-bot Oct 27, 2017
@nickcharlton
Copy link
Member

This is looking great! I'm going to merge this in now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants