-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove jasminerice and use jasmine-gem directly
Use the latest version of jasmine via the jasmine-gem. This supports the asset pipeline natively and works with the latest version of phantomjs. There's no need to use jasminerice anymore. - Add explicit jasmine gem dependency (was being implicitly pulled by guard-jasmine). - Update guard-jasmine. - Remove custom phantomjs download from Travis config file. - Add configuration for jasmine via the jasmine.yml and jasmine_helper.rb. - Rewrite the different page callbacks handling mechanism to make it compatible with the new jasmine harness. Previously the helper was loaded first, before the application JS. Since that's no longer the case, we can't overwrite each onPage function in the helper. Instead, in the onPage function we save the callbacks and execute them on DOM loaded all at once if the relevant piece of DOM is available, or by manually calling runPageCallbacks() from the spec helper. - Fix some compatibility related Jasmine API usages.
- Loading branch information
Showing
27 changed files
with
232 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
# A sample Guardfile | ||
# More info at https://github.com/guard/guard#readme | ||
|
||
guard 'jasmine' do | ||
watch(%r{spec/javascripts/spec\.(js\.coffee|js|coffee)$}) { "spec/javascripts" } | ||
watch(%r{spec/javascripts/.+_spec\.(js\.coffee|js|coffee)$}) | ||
watch(%r{app/assets/javascripts/(.+?)\.(js\.coffee|js|coffee)$}) { |m| "spec/javascripts/#{m[1]}_spec.#{m[2]}" } | ||
guard :jasmine, server_mount: '/' do | ||
watch(%r{^(plugins/(.+)/)?spec/javascripts/.*(?:_s|S)pec\.(coffee|js)$}) | ||
watch(%r{app/assets/javascripts/(.+?)\.(js\.coffee|js|coffee)(?:\.\w+)*$}) do |m| | ||
"spec/javascripts/#{ m[1] }_spec.#{ m[2] }" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
window.onCollections ?= (callback) -> $(-> callback() if $('#collections-main').length > 0) | ||
collectionsCallbacks = [] | ||
window.onCollections = (callback) -> collectionsCallbacks.push(callback) | ||
window.runCollectionsCallbacks = -> callback() for callback in collectionsCallbacks | ||
$ -> runCollectionsCallbacks() if $('#collections-main').length > 0 |
10 changes: 8 additions & 2 deletions
10
app/assets/javascripts/import_wizard/on_import_wizard.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
window.onImportWizard ?= (callback) -> $(-> callback() if $('#import-wizard-main').length > 0) | ||
importWizardCallbacks = [] | ||
window.onImportWizard = (callback) -> importWizardCallbacks.push(callback) | ||
window.runImportWizardCallbacks = -> callback() for callback in importWizardCallbacks | ||
$ -> runImportWizardCallbacks() if $('#import-wizard-main').length > 0 | ||
|
||
window.onImportInProgress ?= (callback) -> $(-> callback() if $('#import-in-progress').length > 0) | ||
importInProgressCallbacks = [] | ||
window.onImportInProgress = (callback) -> importInProgressCallbacks.push(callback) | ||
window.runImportInProgressCallbacks = -> callback() for callback in importInProgressCallbacks | ||
$ -> runImportInProgressCallbacks() if $('#import-in-progress').length > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
window.onLayers ?= (callback) -> $(-> callback() if $('#layers-main').length > 0) | ||
layersCallbacks = [] | ||
window.onLayers = (callback) -> layersCallbacks.push(callback) | ||
window.runLayersCallbacks = -> callback() for callback in layersCallbacks | ||
$ -> runLayersCallbacks() if $('#layers-main').length > 0 |
5 changes: 4 additions & 1 deletion
5
plugins/alerts/assets/javascripts/thresholds/on_thresholds.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
window.onThresholds ?= (callback) -> $(-> callback() if $('#thresholds-main').length > 0) | ||
thresholdsCallbacks = [] | ||
window.onThresholds = (callback) -> thresholdsCallbacks.push(callback) | ||
window.runThresholdsCallbacks = -> callback() for callback in thresholdsCallbacks | ||
$ -> runThresholdsCallbacks() if $('#thresholds-main').length > 0 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
plugins/channels/assets/javascripts/channels/on_channels.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
window.onChannels ?= (callback) -> $(-> callback() if $('#channels-main').length > 0) | ||
channelsCallbacks = [] | ||
window.onChannels = (callback) -> channelsCallbacks.push(callback) | ||
window.runChannelsCallbacks = -> callback() for callback in channelsCallbacks | ||
$ -> runChannelsCallbacks() if $('#channels-main').length > 0 |
53 changes: 26 additions & 27 deletions
53
plugins/channels/spec/javascripts/channels/channel_spec.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,30 @@ | ||
describe 'Channel', -> | ||
xit -> | ||
beforeEach -> | ||
window.runOnCallbacks 'channels' | ||
@collectionId = 1 | ||
@channel = new Channel {id:1, collection_id: @collectionId, name:'Regional (GSM)', ticket_code: '', password: '12345', is_manual_configuration: true, is_share: 'false', share_collections: []}, @collectionId | ||
it 'should have 1 channel', -> | ||
expect(@channel.valid()).toBeTruthy() | ||
xdescribe 'Channel', -> | ||
beforeEach -> | ||
window.runOnCallbacks 'channels' | ||
@collectionId = 1 | ||
@channel = new Channel {id:1, collection_id: @collectionId, name:'Regional (GSM)', ticket_code: '', password: '12345', is_manual_configuration: true, is_share: 'false', share_collections: []}, @collectionId | ||
it 'should have 1 channel', -> | ||
expect(@channel.valid()).toBeTruthy() | ||
|
||
it 'should have property is_admin = true', -> | ||
expect(@channel.isAdmin).toBeTruthy() | ||
it 'should have property is_admin = true', -> | ||
expect(@channel.isAdmin).toBeTruthy() | ||
|
||
it 'should not valid when password less than 4 characters', -> | ||
@channel.password '12' | ||
expect(@channel.valid()).toBeFalsy() | ||
it 'should not valid when password less than 4 characters', -> | ||
@channel.password '12' | ||
expect(@channel.valid()).toBeFalsy() | ||
|
||
it 'should not valid when name less than 4 characters', -> | ||
@channel.name 'ab' | ||
expect(@channel.valid()).toBeFalsy() | ||
it 'should not valid when name less than 4 characters', -> | ||
@channel.name 'ab' | ||
expect(@channel.valid()).toBeFalsy() | ||
|
||
it 'should parsed to Json format', -> | ||
expect(@channel.toJson()).toEqual { | ||
id: 1 | ||
collection_id : @collectionId | ||
name : 'Regional (GSM)' | ||
is_share : 'false' | ||
is_manual_configuration : true | ||
password : '12345' | ||
ticket_code : '' | ||
share_collections : [] | ||
} | ||
it 'should parsed to Json format', -> | ||
expect(@channel.toJson()).toEqual { | ||
id: 1 | ||
collection_id : @collectionId | ||
name : 'Regional (GSM)' | ||
is_share : 'false' | ||
is_manual_configuration : true | ||
password : '12345' | ||
ticket_code : '' | ||
share_collections : [] | ||
} |
123 changes: 61 additions & 62 deletions
123
plugins/channels/spec/javascripts/channels/main_view_model_spec.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,62 @@ | ||
describe 'MainViewModel', -> | ||
xit -> | ||
xdescribe 'MainViewModel', -> | ||
beforeEach -> | ||
window.runOnCallbacks 'channels' | ||
@collectionId =1 | ||
@model = new MainViewModel @collectionId | ||
window.model = @model | ||
|
||
describe 'create threshold', -> | ||
beforeEach -> | ||
window.runOnCallbacks 'channels' | ||
@collectionId =1 | ||
@model = new MainViewModel @collectionId | ||
window.model = @model | ||
|
||
describe 'create threshold', -> | ||
beforeEach -> | ||
@model.addChannel() | ||
|
||
it 'should add channel to channels', -> | ||
expect(@model.channels().length).toEqual 1 | ||
|
||
it 'should add channel to channels with property isAdmin = true', -> | ||
expect(@model.channels()[0].isAdmin).toEqual true | ||
|
||
it 'should add channel to channels with property queued_messages_count = 0', -> | ||
expect(@model.channels()[0].queuedMessageText()).toMatch(/Client disconected,0 message pending/) | ||
|
||
it 'should add channel to channels with is_manual_configuration = true', -> | ||
expect(@model.channels()[0].isManualConfiguration()).toBeTruthy | ||
|
||
it 'should add channel to channels with is_share = true', -> | ||
expect(@model.channels()[0].isShare()).toMatch(/false/) | ||
|
||
describe 'edit channel', -> | ||
beforeEach -> | ||
@channel = new Channel {id:1, collection_id: @collectionId, name:'Regional (GSM)', password: '12345', is_enable: true, nuntium_channel_name: 'ch_01', is_manual_configuration: true, is_share: false, collections: [{id: 3, name: 'col 1'}, {id: 2, name: 'col 02'}]} | ||
@model.channels.push @channel | ||
@model.editChannel @channel | ||
|
||
it 'should restore channel name after cancel', -> | ||
@model.channels()[0].name() | ||
@model.cancelChannel() | ||
expect(@model.channels()[0].name()).toEqual('Regional (GSM)') | ||
|
||
it "should restore channel's password after cancel", -> | ||
@model.channels()[0].password(9999) | ||
@model.cancelChannel() | ||
expect(@model.channels()[0].password()).toMatch(/12345/) | ||
|
||
it "should restore channel's shared_collections after cancel", -> | ||
@model.channels()[0].sharedCollections() | ||
@model.cancelChannel() | ||
expect(@model.channels()[0].sharedCollections()).toEqual [{id: 3, name: 'col 1'}, {id: 2, name: 'col 02'}] | ||
|
||
describe 'delete channel', -> | ||
beforeEach -> | ||
@channel = new Channel {id:1, collection_id: @collectionId, name:'Regional (GSM)', is_enable: true, nuntium_channel_name: 'ch_01', is_manual_configuration: true, is_share: false, collections: [{id: 1, name: 'col 1'}, {id: 2, name: 'col 02'}]} | ||
@model.channels.push @channel | ||
|
||
it 'should show confirm dialog', -> | ||
spyOn window, 'confirm' | ||
@model.deleteChannel @channel | ||
expect(window.confirm).toHaveBeenCalledWith 'Are you sure to delete channel?' | ||
|
||
it 'should delete the channel', -> | ||
spyOn(window, 'confirm').andReturn true | ||
spyOn($, 'post').andReturn true | ||
@model.deleteChannel @channel | ||
@expect($.post).toHaveBeenCalledWith "/plugin/channels/collections/#{@collectionId}/channels/#{@channel.id}.json", { _method: 'delete' }, @model.deleteChannelCallback | ||
@model.addChannel() | ||
|
||
it 'should add channel to channels', -> | ||
expect(@model.channels().length).toEqual 1 | ||
|
||
it 'should add channel to channels with property isAdmin = true', -> | ||
expect(@model.channels()[0].isAdmin).toEqual true | ||
|
||
it 'should add channel to channels with property queued_messages_count = 0', -> | ||
expect(@model.channels()[0].queuedMessageText()).toMatch(/Client disconected,0 message pending/) | ||
|
||
it 'should add channel to channels with is_manual_configuration = true', -> | ||
expect(@model.channels()[0].isManualConfiguration()).toBeTruthy | ||
|
||
it 'should add channel to channels with is_share = true', -> | ||
expect(@model.channels()[0].isShare()).toMatch(/false/) | ||
|
||
describe 'edit channel', -> | ||
beforeEach -> | ||
@channel = new Channel {id:1, collection_id: @collectionId, name:'Regional (GSM)', password: '12345', is_enable: true, nuntium_channel_name: 'ch_01', is_manual_configuration: true, is_share: false, collections: [{id: 3, name: 'col 1'}, {id: 2, name: 'col 02'}]} | ||
@model.channels.push @channel | ||
@model.editChannel @channel | ||
|
||
it 'should restore channel name after cancel', -> | ||
@model.channels()[0].name() | ||
@model.cancelChannel() | ||
expect(@model.channels()[0].name()).toEqual('Regional (GSM)') | ||
|
||
it "should restore channel's password after cancel", -> | ||
@model.channels()[0].password(9999) | ||
@model.cancelChannel() | ||
expect(@model.channels()[0].password()).toMatch(/12345/) | ||
|
||
it "should restore channel's shared_collections after cancel", -> | ||
@model.channels()[0].sharedCollections() | ||
@model.cancelChannel() | ||
expect(@model.channels()[0].sharedCollections()).toEqual [{id: 3, name: 'col 1'}, {id: 2, name: 'col 02'}] | ||
|
||
describe 'delete channel', -> | ||
beforeEach -> | ||
@channel = new Channel {id:1, collection_id: @collectionId, name:'Regional (GSM)', is_enable: true, nuntium_channel_name: 'ch_01', is_manual_configuration: true, is_share: false, collections: [{id: 1, name: 'col 1'}, {id: 2, name: 'col 02'}]} | ||
@model.channels.push @channel | ||
|
||
it 'should show confirm dialog', -> | ||
spyOn window, 'confirm' | ||
@model.deleteChannel @channel | ||
expect(window.confirm).toHaveBeenCalledWith 'Are you sure to delete channel?' | ||
|
||
it 'should delete the channel', -> | ||
spyOn(window, 'confirm').and.returnValue true | ||
spyOn($, 'post').and.returnValue true | ||
@model.deleteChannel @channel | ||
@expect($.post).toHaveBeenCalledWith "/plugin/channels/collections/#{@collectionId}/channels/#{@channel.id}.json", { _method: 'delete' }, @model.deleteChannelCallback |
This file was deleted.
Oops, something went wrong.
5 changes: 4 additions & 1 deletion
5
plugins/reminders/assets/javascripts/reminders/on_reminders.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
window.onReminders ?= (callback) -> $(-> callback() if $('#reminders-main').length > 0) | ||
remindersCallbacks = [] | ||
window.onReminders = (callback) -> remindersCallbacks.push(callback) | ||
window.runRemindersCallbacks = -> callback() for callback in remindersCallbacks | ||
$ -> runRemindersCallbacks() if $('#reminders-main').length > 0 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.