Skip to content

added specs and validations for Role model#5792

Merged
jhass merged 1 commit intodiaspora:developfrom
MothOnMars:4020-role-specs
Mar 20, 2015
Merged

added specs and validations for Role model#5792
jhass merged 1 commit intodiaspora:developfrom
MothOnMars:4020-role-specs

Conversation

@MothOnMars
Copy link
Copy Markdown
Contributor

  • added shoulda-matchers gem for one-line specs
  • added FactoryGirl syntax methods

Partial fix for #4020

I also added a few validations that seemed to make sense for roles, and tweaked the Role.is_admin? method to return a boolean. Hopefully CI will catch any issues that these changes may cause, but please let me know if I should back out any of those changes to the model itself.

Comment thread app/models/role.rb Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Space inside { detected.
Space inside } detected.

@jhass
Copy link
Copy Markdown
Member

jhass commented Mar 17, 2015

Mh, I'm not sure I like shoulda-matchers, it feels inconsistent with the expect syntax.

@MothOnMars
Copy link
Copy Markdown
Contributor Author

@jhass, the one-line syntax used by shoulda-matchers is supported by RSpec, even when using the expect syntax: https://github.com/rspec/rspec-expectations/blob/master/Should.md#one-liners

I feel that the inconsistency is a small trade-off for being able to write a one-liner instead of multiple lines. It's a solid Thoughtbot gem with great support & documentation. It's probably saved me hundreds of hours and thousands of lines of spec code over the years. Check it out...let me know what you think...and in the meantime, I'll start making Hound happier... 😄

@jhass
Copy link
Copy Markdown
Member

jhass commented Mar 17, 2015

Mh, okay deal, we can try it for a while.

Comment thread spec/spec_helper.rb Outdated
Copy link
Copy Markdown

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.

Comment thread spec/spec_helper.rb Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.

- added shoulda-matchers gem for one-line specs
- added FactoryGirl syntax methods
@jhass
Copy link
Copy Markdown
Member

jhass commented Mar 20, 2015

Thank you!

@jhass jhass merged commit d4f1a5d into diaspora:develop Mar 20, 2015
jhass added a commit that referenced this pull request Mar 20, 2015
added specs and validations for Role model
@jhass jhass added this to the next-major milestone Mar 20, 2015
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