Skip to content
Extraits de code Groupes Projets
Valider e77a401d rédigé par Dennis Schubert's avatar Dennis Schubert
Parcourir les fichiers

Merge pull request #5458 from jhass/stabilize_cukes

Stabilize cukes
parents 9d5e1f60 63e9d7b7
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -21,7 +21,14 @@ app.models.StreamAspects = app.models.Stream.extend({
var url = this.url();
var ids = this.aspects_ids;
this.deferred = this.items.fetch(this._fetchOpts({url : url, data : { 'a_ids': ids }}))
.done(_.bind(this.triggerFetchedEvents, this));
.done(_.bind(this.fetchDone, this));
},
fetchDone: function() {
this.triggerFetchedEvents();
if (app.aspects) {
app.aspects.trigger('aspectStreamFetched');
}
}
});
// @license-end
......
......@@ -14,7 +14,7 @@ app.views.Aspect = app.views.Base.extend({
toggleAspect: function(evt) {
if (evt) { evt.preventDefault(); };
this.model.toggleSelected();
this.$el.find('.icons-check_yes_ok').toggleClass('selected');
app.router.aspects_stream();
},
......
......@@ -12,6 +12,7 @@ app.views.AspectsList = app.views.Base.extend({
initialize: function() {
this.collection.on('change', this.toggleSelector, this);
this.collection.on('change', this.updateStreamTitle, this);
this.collection.on('aspectStreamFetched', this.updateAspectList, this);
},
postRenderTemplate: function() {
......@@ -30,17 +31,10 @@ app.views.AspectsList = app.views.Base.extend({
toggleAll: function(evt) {
if (evt) { evt.preventDefault(); };
var aspects = this.$('li:not(:last)')
if (this.collection.allSelected()) {
this.collection.deselectAll();
aspects.each(function(i){
$(this).find('.icons-check_yes_ok').removeClass('selected');
});
} else {
this.collection.selectAll();
aspects.each(function(i){
$(this).find('.icons-check_yes_ok').addClass('selected');
});
}
this.toggleSelector();
......@@ -60,6 +54,17 @@ app.views.AspectsList = app.views.Base.extend({
$('.stream_title').text(this.collection.toSentence());
},
updateAspectList: function() {
this.collection.each(function(aspect) {
var element = this.$("li[data-aspect_id="+aspect.get('id')+"]");
if (aspect.get('selected')) {
element.find('.icons-check_yes_ok').addClass('selected');
} else {
element.find('.icons-check_yes_ok').removeClass('selected');
}
});
},
hideAspectsList: function() {
this.$el.empty();
},
......
......@@ -91,14 +91,14 @@ end
Then /^I should see "([^"]*)" aspect selected$/ do |aspect_name|
aspect = @me.aspects.where(:name => aspect_name).first
within("#aspects_list") do
page.should have_css "li[data-aspect_id='#{aspect.id}'] .selected"
current_scope.should have_css "li[data-aspect_id='#{aspect.id}'] .selected"
end
end
Then /^I should see "([^"]*)" aspect unselected$/ do |aspect_name|
aspect = @me.aspects.where(:name => aspect_name).first
within("#aspects_list") do
page.should have_no_css "li[data-aspect_id='#{aspect.id}'] .selected"
current_scope.should have_no_css "li[data-aspect_id='#{aspect.id}'] .selected"
end
end
......
RSpec::Matchers.define :have_path do |expected|
match do |actual|
await_condition { actual.current_path == expected }
end
failure_message_for_should do |actual|
"expected #{actual.inspect} to have path #{expected.inspect} but was #{actual.current_path.inspect}"
end
failure_message_for_should_not do |actual|
"expected #{actual.inspect} to not have path #{expected.inspect} but it had"
end
end
RSpec::Matchers.define :have_value do |expected|
match do |actual|
await_condition { actual.value && actual.value.include?(expected) }
end
failure_message_for_should do |actual|
"expected #{actual.inspect} to have value #{expected.inspect} but was #{actual.value.inspect}"
end
failure_message_for_should_not do |actual|
"expected #{actual.inspect} to not have value #{expected.inspect} but it had"
end
end
def await_condition &condition
start_time = Time.now
until condition.call
return false if (Time.now-start_time) > Capybara.default_wait_time
sleep 0.05
end
true
end
......@@ -66,8 +66,7 @@ module NavigationHelpers
end
def confirm_on_page(page_name)
current_path = URI.parse(current_url).path
expect(current_path).to eq(path_to(page_name))
expect(page).to have_path(path_to(page_name))
end
end
......
......@@ -4,11 +4,11 @@ module PublishingCukeHelpers
end
def append_to_publisher(txt, input_selector='#status_message_fake_text')
elem = find(input_selector, visible: false)
elem = find(input_selector)
elem.native.send_keys(' ' + txt)
# make sure the other text field got the new contents
expect(page).to have_xpath("//input|textarea/.[@id='status_message_text' and contains(@value, '#{txt}')]", visible: false)
expect(find("#status_message_text", visible: false)).to have_value txt
end
def upload_file_with_publisher(path)
......
......@@ -28,7 +28,6 @@ describe("app.views.Aspect", function(){
it('it should deselect the aspect', function(){
this.view.$el.children('a.selectable').trigger('click');
expect(this.view.toggleAspect).toHaveBeenCalled();
expect(this.view.$el.children('.icons-check_yes_ok').hasClass('selected')).toBeFalsy();
expect(app.router.aspects_stream).toHaveBeenCalled();
});
......
......@@ -48,7 +48,6 @@ describe("app.views.AspectsList", function(){
it('should show all the aspects selected', function(){
expect(this.view.toggleAll).toHaveBeenCalled();
expect(this.view.$('.selected').length).toBe(3);
});
it('should show \'Deselect all\' link', function(){
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter