Skip to content

Add modelToIgnore option - #25

Merged
bajtos merged 1 commit into
strongloop:masterfrom
aquid:master
Sep 13, 2016
Merged

bajtos merged 1 commit into
strongloop:masterfrom
aquid:master

Conversation

@aquid

@aquid aquid commented Jun 15, 2016

Copy link
Copy Markdown
Contributor

… contains a list of models that are to be prevented from being published in loopback angular SDK.

@bajtos You will have to update the package.json with right version number , once you accept and publish the PR,
strongloop/loopback-sdk-angular#224

@slnode

slnode commented Jun 15, 2016

Copy link
Copy Markdown

Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test."

@aquid

aquid commented Aug 24, 2016

Copy link
Copy Markdown
Contributor Author

@bajtos Any updates on this?

@slnode

slnode commented Aug 24, 2016

Copy link
Copy Markdown

Can one of the admins verify this patch?

Comment thread package.json Outdated
},
"dependencies": {
"loopback-sdk-angular": "^1.2.0"
"loopback-sdk-angular": "https://github.com/aquid/loopback-sdk-angular/tarball/master"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please revert

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Even better, change the dependency version spec to ^1.10.0 to ensure we have a version that supports modelsToIgnore option.

@bajtos

bajtos commented Aug 24, 2016

Copy link
Copy Markdown
Member

@aquid please add a unit-test to verify this change. IIRC, you will need to add a new section to

// Configuration to be run (and then tested).
loopback_sdk_angular: {
options: {
input: 'test/fixtures/app.js'
},
default_options: {
options: {
output: 'tmp/default_options'
}
},
custom_options: {
options: {
output: 'tmp/custom_options',
ngModuleName: 'customServices',
apiUrl: 'http://custom/api/'
}
}
},
and then a test case here:
default_options: function(test) {
var script = grunt.file.read('tmp/default_options');
// the value "lbservices" is the --module-name default
test.equal(parse.moduleName(script), 'lbServices');
// the value "/rest-api-root" is hard-coded in fixtures/app.js
test.equal(parse.baseUrl(script), '/rest-api-root');
test.done();
},
custom_options: function(test) {
var script = grunt.file.read('tmp/custom_options');
test.equal(parse.moduleName(script), 'customServices');
test.equal(parse.baseUrl(script), 'http://custom/api');
test.done();
}

@bajtos

bajtos commented Aug 24, 2016

Copy link
Copy Markdown
Member

@aquid also please rebase your patch on top of the current master and make sure the commit messages are following the 50/72 rule.

@bajtos bajtos added the waiting label Sep 6, 2016
@bajtos

bajtos commented Sep 6, 2016

Copy link
Copy Markdown
Member

@aquid ping, what's the status of this pull request? Are you still keen to get it finished?

@aquid

aquid commented Sep 6, 2016 •

Copy link
Copy Markdown
Contributor Author

@bajtos Apologies for the delay but, I am on it. Just need some time to add unit tests. Have to finish some other projects, once that are done will work on the PR.

@aquid

aquid commented Sep 7, 2016

Copy link
Copy Markdown
Contributor Author

@bajtos Is there a way to test modelsToIgnore in our unit test? Right now I can just test the equality of moduleName and baseUrl apart from this I don't think we can test anything else.

What I have done till now is this

Gruntfile.js: 

ignore_models_option: {
        options: {
          output: 'tmp/ignore_models_option',
          ngModuleName: 'modelsToIgnoreService',
          modelsToIgnore : ['customModel_1','customModel_2']
        }
      }


loopback_sdk_angular_test.js:

ignore_models_option: function(test) {
    var script = grunt.file.read('tmp/ignore_models_option');
    test.equal(parse.moduleName(script), 'modelsToIgnoreService');
    // This won't work as there's no export for this.
    // test.equal(parse.modelsToIgnore(script), ['customModel_1','customModel_2']);
    test.done();
  }

Will that be enough for the tests?

@aquid

aquid commented Sep 7, 2016

Copy link
Copy Markdown
Contributor Author

@bajtos I have updated the PR. Please let me know if there's anything else that I should add here.

@bajtos

bajtos commented Sep 7, 2016

Copy link
Copy Markdown
Member

Will that be enough for the tests?

    // This won't work as there's no export for this.
    // test.equal(parse.modelsToIgnore(script), ['customModel_1','customModel_2']);

You can check that the script does not contain any of these models. Something along the following lines:

// assuming User model is ignored
test.ok(script.indexOf('User') === -1);

Also make sure to see your test fail. For example, the currently proposed test excluding customModel_1 will always pass, because there is no customModel_1 in the fixture app.

Comment thread package.json
"grunt-contrib-nodeunit": "^1.0.0",
"loopback": "^1.7.4",
"loopback-datasource-juggler": "^1.3.10"
"loopback": "^2.0.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@bajtos Changed the version because of this issue

@aquid

aquid commented Sep 7, 2016

Copy link
Copy Markdown
Contributor Author

@bajtos Updated PR with custom models initialization and tests to verify if models are ignored properly.

Comment thread test/fixtures/app.js Outdated

// Create custom models extending Model
var CustomModel_1 = Model.extend('CustomModel_1', {}, {
trackChanges: true,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is trackChanges needed? AFAICT, your test is not using this feature at all.

@bajtos

bajtos commented Sep 8, 2016

Copy link
Copy Markdown
Member

@aquid almost there :) See my comment above, and also please edit the first line of the commit message to mention "modelsToIgnore option".

- Changed looback-sdk-angular version to support modelsToIgnore option

- Changed multiple arguments into single options argument for generator

- Added unit test to verify the change
@aquid

aquid commented Sep 8, 2016

Copy link
Copy Markdown
Contributor Author

@bajtos Hopefully fixed everything this time. Waiting for your response. (Fingers crossed).

@bajtos

bajtos commented Sep 13, 2016

Copy link
Copy Markdown
Member

@slnode ok to test

@bajtos
bajtos merged commit e6e4768 into strongloop:master Sep 13, 2016
@bajtos bajtos changed the title Added modelToIgnore option which… Add modelToIgnore option Sep 13, 2016
@slnode

slnode commented Sep 13, 2016

Copy link
Copy Markdown

Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test."

@slnode

slnode commented Sep 13, 2016

Copy link
Copy Markdown

Can one of the admins verify this patch?

@bajtos

bajtos commented Sep 13, 2016

Copy link
Copy Markdown
Member

Landed, thank you for the contribution!

@bajtos

bajtos commented Sep 13, 2016

Copy link
Copy Markdown
Member

Released as grunt-loopback-sdk-angular@1.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants