refactor js and cucumber scenario for integrations page

This commit is contained in:
Reinier Balt 2010-11-10 16:52:05 +01:00
parent d1b35090ab
commit 05b3b7cebc
5 changed files with 37 additions and 52 deletions

View file

@ -71,7 +71,7 @@ Feature: Manage the list of contexts
| active | @phone |
| hidden | @hidden|
@selenium @wip
@selenium
Scenario: Cannot add a context with comma in the name
When I go to the contexts page
And I add a new active context "foo, bar"

View file

@ -21,7 +21,6 @@ Feature: Existing user logging in
| admin | secret | redirected to the home page | Login successful |
| admin | wrong | on the login page | Login unsuccessful |
@wip
Scenario Outline: Unauthorized users cannot access Tracks and need to log in first
Given there exists a project called "top secret" for user "testuser"
And there exists a context called "@secret location" for user "testuser"

View file

@ -108,7 +108,7 @@ Feature: Manage the list of projects
When I sort the list by number of tasks
Then the project "very busy" should be above the project "test"
@selenium @wip
@selenium
Scenario: Cannot add a project with comma in the name
When I go to the projects page
And I submit a new project with name "foo,bar"

View file

@ -9,6 +9,12 @@ Feature: Integrate Tracks in various ways
| login | password | is_admin |
| testuser | secret | false |
And I have logged in as "testuser" with password "secret"
And I have the following contexts:
| context |
| @pc |
| @home |
| @shops |
| @boss |
Scenario: I cannot see scripts when I do not have a context
Given I have no contexts
@ -21,18 +27,20 @@ Feature: Integrate Tracks in various ways
Then I should see scripts
@selenium
Scenario: When I select a different context the example scripts should change accoordingly
Given I have the following contexts:
| context |
| @pc |
| @home |
| @shops |
| @boss |
Scenario: The scripts on the page should be prefilled with the first context
When I go to the integrations page
Then I should see a script "applescript1" for "@pc"
When I select "@home" from "applescript1-contexts"
Then I should see a script "applescript1" for "@home"
When I select "@shops" from "applescript2-contexts"
Then I should see a script "applescript2" for "@shops"
When I select "@boss" from "quicksilver-contexts"
Then I should see a script "quicksilver" for "@boss"
@selenium
Scenario Outline: When I select a different context the example scripts should change accordingly
When I go to the integrations page
When I select "<context1>" from "<context-list>"
Then I should see a script "<script>" for "<context1>"
When I select "<context2>" from "<context-list>"
Then I should see a script "<script>" for "<context2>"
Examples:
| context1 | context2 | context-list | script |
| @home | @boss | applescript1-contexts | applescript1 |
| @shops | @home | applescript2-contexts | applescript2 |
| @boss | @shops | quicksilver-contexts | quicksilver |

View file

@ -90,6 +90,19 @@ var ContextListPage = {
}
}
var IntegrationsPage = {
setup_behavior: function () {
$('#applescript1-contexts').live('change', function(){
$("#applescript1").load(relative_to_root('integrations/get_applescript1?context_id='+this.value));
});
$('#applescript2-contexts').live('change', function(){
$("#applescript2").load(relative_to_root('integrations/get_applescript2?context_id='+this.value));
});
$('#quicksilver-contexts').live('change', function(){
$("#quicksilver").load(relative_to_root('integrations/get_quicksilver_applescript?context_id='+this.value));
});
}
}
$.fn.clearForm = function() {
return this.each(function() {
@ -726,42 +739,7 @@ $(document).ready(function() {
$("#feeds-for-project").load('/feedlist/get_feeds_for_project?project_id='+this.value);
});
/* Integrations page */
/*
<%= observe_field "applescript1-contexts", :update => "applescript1",
:with => 'context_id',
:url => { :controller => "integrations", :action => "get_applescript1" },
:before => "$('applescript1').startWaiting()",
:complete => "$('applescript1').stopWaiting()"
%>
*/
$('#applescript1-contexts').live('change', function(){
$("#applescript1").load(relative_to_root('integrations/get_applescript1?context_id='+this.value));
});
/*
<%= observe_field "applescript2-contexts", :update => "applescript2",
:with => 'context_id',
:url => { :controller => "integrations", :action => "get_applescript2" },
:before => "$('applescript2').startWaiting()",
:complete => "$('applescript2').stopWaiting()"
%>
*/
$('#applescript2-contexts').live('change', function(){
$("#applescript2").load(relative_to_root('integrations/get_applescript2?context_id='+this.value));
});
/*
<%= observe_field "quicksilver-contexts", :update => "quicksilver",
:with => 'context_id',
:url => { :controller => "integrations", :action => "get_quicksilver_applescript" },
:before => "$('quicksilver').startWaiting()",
:complete => "$('quicksilver').stopWaiting()"
%>
*/
$('#quicksilver-contexts').live('change', function(){
$("#quicksilver").load(relative_to_root('integrations/get_quicksilver_applescript?context_id='+this.value));
});
IntegrationsPage.setup_behavior();
/* Gets called from some AJAX callbacks, too */
enable_rich_interaction();