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

Use actionmodel naming for calculators #1546

Merged

Conversation

gevann
Copy link

@gevann gevann commented Oct 20, 2016

This PR is based on #1538 and closes #1544

@@ -4,6 +4,11 @@
let(:calculator) { Spree::Calculator::FlatPercentItemTotal.new }
let(:line_item) { mock_model Spree::LineItem }

describe ".description" do
subject{ described_class.description }
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a space missing here before the opening {. Can you add that one space? I know it's lots of commits to go and edit, but interactive rebase makes that pretty straightforward. Read up here about it, it's great. And yes, please force push afterwards, we don't mind for open PRs before they're merged.

@gevann gevann force-pushed the use-actionmodel-naming-for-calculators branch 2 times, most recently from d753171 to 1404117 Compare October 20, 2016 21:45
@tvdeyen
Copy link
Member

tvdeyen commented Oct 20, 2016

Thanks for your contribution.

I don't see any value in testing these descriptions. Especially if we hard core translations inside tests. That only means broken builds if we update a translation.

There is no business logic included at all that needed testing.

So, from my point of view we should just remove them.

@gevann gevann force-pushed the use-actionmodel-naming-for-calculators branch from 1404117 to 34ca4cf Compare October 20, 2016 22:02
@mamhoff
Copy link
Contributor

mamhoff commented Oct 21, 2016

OK, @tvdeyen this makes sense. My fault here for providing an example test... Maybe add a spec for the base calculator to call model_name.human instead? @gevann you can do that in an additional commit.

@gevann
Copy link
Author

gevann commented Oct 21, 2016

@mamhoff no problem, I'll take care of that as you and @tvdeyen have suggested. Thanks for the feedback.

@gevann
Copy link
Author

gevann commented Oct 21, 2016

@tvdeyen @mamhoff, spoke with @cbrunsdon, he says to keep the tests despite the hard-coding.

@cbrunsdon
Copy link
Contributor

Yea, I'm pro leaving the tests in. Since we're testing the output, which is the text string, not the implementation, which we know goes through standard rails i18n.

@tvdeyen
Copy link
Member

tvdeyen commented Oct 21, 2016

Testing a random string has no value for me. Why don't we test all other strings then, why exactly these strings? Are they special, and when yes, what makes them special?

The only value I see is that we ensure all calculators inherit from Spree::Calculator. Why not test this then?

Sorry, still not convinced, but I don't resist on removing them. If anybody these value in them, please keep em.

I only care about less burdens.

@cbrunsdon
Copy link
Contributor

I'd be okay with something like a shared example for calculators that just tested that there was a non-zero length string there

@tvdeyen
Copy link
Member

tvdeyen commented Oct 21, 2016

it_behaves_like "having a description" 👍

Like that

@@ -9,6 +10,11 @@
let(:included_in_price) { false }
subject(:calculator) { Spree::Calculator::DefaultTax.new(calculable: rate ) }

describe ".description" do
Copy link
Member

Choose a reason for hiding this comment

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

You can even put the whole describe block including the subject in the shared example so that you only have to leave it_behaves_like in the calculator specs.

Copy link
Contributor

Choose a reason for hiding this comment

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

@gevann I second this thought. In the individual calculator specs, we only want to see something like it_behaves_like "a calculator with a description". The describe block can go into the shared example.

@@ -0,0 +1,5 @@
shared_examples_for 'having a description' do
it "has a description" do
expect(subject.size).to be > 0
Copy link
Member

Choose a reason for hiding this comment

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

I think expecting a String would be better. Every enumerable has a size method.

@@ -1,4 +1,5 @@
require 'spec_helper'
require 'spree/testing_support/calculator_helpers'
Copy link
Member

Choose a reason for hiding this comment

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

The term helper would lead to the impression that this file provides some preparation or tear down related stuff.

Why not call this file shared_calculator_examples or we could add another folder shared_examples and put a calculators file into it.

WDYT @cbrunsdon ?

Copy link
Author

Choose a reason for hiding this comment

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

I think a new folder would be clearest -- I didn't want to add one myself as I'm new to Solidus, so I just chose a place where I found other shared examples being defined currently.

@tvdeyen
Copy link
Member

tvdeyen commented Oct 22, 2016

Sorry for being so picky!

@gevann gevann force-pushed the use-actionmodel-naming-for-calculators branch from 61f6c19 to aa1bfdf Compare October 25, 2016 17:11
@mtomov
Copy link
Contributor

mtomov commented Oct 28, 2016

@tvdeyen I would've been on the same board as you, so not to worry : ), but the way the shared example is implemented is just great! Thanks!

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

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

This is perfect now! Thanks for being so patience

@tvdeyen
Copy link
Member

tvdeyen commented Oct 28, 2016

@mamhoff you requested changes that where now made.
Would you mind to review again? Thanks

Copy link
Contributor

@mamhoff mamhoff left a comment

Choose a reason for hiding this comment

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

Yep, now we're there. Perfect!

@jhawthorn jhawthorn merged commit b75eb29 into solidusio:master Oct 28, 2016
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.

Use ActiveModel::Naming for calculator descriptions
6 participants