Improvements to ActiveJS

The ability to create relations between the different objects of the application (a user has many articles, a section has one HTML content) was believed to be implemented in ActiveJS as it is implemented in Ruby on Rails.

An attempt to define the relations between articles and sections was implemented as follows:

[code lang="js"]
Section = ActiveRecord.create('sections', {});

Article = ActiveRecord.create('articles', {
created_at: '',
updated_at: ''
});

Section.belongsTo( Article );
[/code]

And when relations were to be set between instances of the User and Article class:

[code lang="js"]
article1 = Article.create({
created_at: now(),
updated_at: now()
});
section1 = Section.create({ });
section1.createArticle( article1 );
[/code]

It appeared however that those two assumptions were false. ActiveJS in its official implementation requires the following to be written:

[code lang="js"]
Section = ActiveRecord.create('sections', {
article_id: ''
});

Article = ActiveRecord.create('articles', {
created_at: '',
updated_at: ''
});
Section.belongsTo( Article );
[/code]

[code lang="js"]
section1 = Section.create({ });
section1.createArticle({
created_at: now(),
updated_at: now()
});
[/code]

The fact that it was not possible to use pre-existing objects when creating a relation between two objects penalising problem, as it was actually impossible in the application to create a presentation once all of its slides were created.

Instead of working around those two issues, it was decided to spend some time implementing the missing features. The first two snippets of code can now successfully be used with the improved version of ActiveJS and additional unit tests were added to the existing one to ensure that those change will still work with future versions of the framework.