-
Notifications
You must be signed in to change notification settings - Fork 116
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
Add epilogue.initialize([options.resource]) #137
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,7 +78,7 @@ describe('Resource(basic)', function() { | |
// TESTS | ||
describe('construction', function() { | ||
it('should throw an exception if called with an invalid model', function(done) { | ||
expect(rest.resource).to.throw('please specify a valid model'); | ||
expect(rest.resource.bind(rest)).to.throw('please specify a valid model'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mbroadst I had to edit this test because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gotcha, nice catch |
||
done(); | ||
}); | ||
|
||
|
@@ -89,7 +89,16 @@ describe('Resource(basic)', function() { | |
expect(exception).to.eql(new Error('resource needs a model')); | ||
done(); | ||
} | ||
}); | ||
|
||
it('should extend default options', function() { | ||
rest.defaultOptions.resource = { pagination: false }; | ||
|
||
var resource = rest.resource({ | ||
model: test.models.Person | ||
}); | ||
|
||
expect( resource.pagination ).to.be.equal( false ); | ||
}); | ||
|
||
it('should auto generate endpoints if none were provided', function() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you think it makes a little more sense to embed this in a section called
defaults
? like:we already know semantically that we will be dealing with resources, so
resource
sounds redundant to me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly I don't know, but I don't feel right giving non-semantic definitions on things we don't know if they will change. I've understood why you prefer so, but with
defaults
key I would see something more like:defaults: { resource: { /* ... */ } }
(In fact I was going to implement that way but I've changed my mind because sequelize is using{ define: { /* defaults for define */ } }
).My motto is always to avoid future BC by having good implementations. Even if this is only creating
resources
, it doesn't mean we could introduce another kind of bindings later.But it is your decision, tell me what you think about, I will write it. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
{ defaults: { resource ...
is a good compromise. The existing keys are going to be global to the module (app
,sequelize
). Arguably, so would have beenresource
, as after all epilogue is chiefly interested in creating resources - however, I get your point and I think this would be a good middle ground.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, you are meaning it would stay as it is or do I have to change anything here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would become:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the fact that epilogue only creates resources, I am making up in my mind features to enhance productivity that could change that fact, but I would let that discussion to later as soon as I have an architecture well formed.