Skip to content

Commit

Permalink
integrate @dsander's suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
cantino committed Apr 13, 2015
1 parent fae3dbf commit 8b1bc3c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
20 changes: 9 additions & 11 deletions app/assets/javascripts/pages/agent-edit-page.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -136,24 +136,22 @@ class @AgentEditPage
$source = $($(this).data('source')).hide()
editor = ace.edit(this)
$(this).data('ace-editor', editor)
editor.getSession().setTabSize(2)
editor.getSession().setUseSoftTabs(true)
editor.getSession().setUseWrapMode(false)
session = editor.getSession()
session.setTabSize(2)
session.setUseSoftTabs(true)
session.setUseWrapMode(false)
editor.setTheme("ace/theme/chrome")

setSyntax = ->
syntax = $("[name='agent[options][language]']").val()
if syntax == 'JavaScript'
editor.getSession().setMode("ace/mode/javascript")
else if syntax == 'CoffeeScript'
editor.getSession().setMode("ace/mode/coffee")
else
editor.getSession().setMode("ace/mode/text")
switch $("[name='agent[options][language]']").val()
when 'JavaScript' then session.setMode("ace/mode/javascript")
when 'CoffeeScript' then session.setMode("ace/mode/coffee")
else session.setMode("ace/mode/text")

$("[name='agent[options][language]']").on 'change', setSyntax
setSyntax()

editor.getSession().setValue($source.val())
session.setValue($source.val())

updateFromEditors: ->
$(".ace-editor").each ->
Expand Down
13 changes: 5 additions & 8 deletions spec/models/agents/java_script_agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,11 @@
expect(@agent).to be_valid
@agent.options['language'] = 'foo'
expect(@agent).not_to be_valid
@agent.options['language'] = 'javascript'
expect(@agent).to be_valid
@agent.options['language'] = 'JavaScript'
expect(@agent).to be_valid
@agent.options['language'] = 'coffeescript'
expect(@agent).to be_valid
@agent.options['language'] = 'CoffeeScript'
expect(@agent).to be_valid

%w[javascript JavaScript coffeescript CoffeeScript].each do |valid_language|
@agent.options['language'] = valid_language
expect(@agent).to be_valid
end
end

it "accepts a credential, but it must exist" do
Expand Down

0 comments on commit 8b1bc3c

Please sign in to comment.