X-Git-Url: https://nos-oignons.net/gitweb/gestion-adh.git/blobdiff_plain/8bbb07a1bc5db944ba95fa5951ed40c3c1b968aa..13767cc69697b7eaf4be6e47788efe636b56b6fd:/features/step_definitions/subscriptions.rb diff --git a/features/step_definitions/subscriptions.rb b/features/step_definitions/subscriptions.rb index 76a4a1a..dd18151 100644 --- a/features/step_definitions/subscriptions.rb +++ b/features/step_definitions/subscriptions.rb @@ -1,3 +1,39 @@ +#-*- coding: utf-8 -*- + +Given /une base de membres vide$/ do + create_dir 'Membres' +end + +Given /^(?:une base )?avec (\w+)(, à jour de cotisation| qui n'a pas payé sa cotisation cette année)$/ do |name, uptodate| + case uptodate + when ', à jour de cotisation' + # ± 1 month ago + paid_on = (Time.now - 3600*24*30).strftime('%Y-%m-%d') + else + # ± 15 months ago + paid_on = (Time.now - 3600*24*30*15).strftime('%Y-%m-%d') + end + data = { 'name' => name, + 'address' => "At #{name}", + 'email' => "#{name.downcase}@example.org", + 'membership_fee_paid_on' => paid_on + } + create_dir 'Membres' + file = subscription_filename_for_id(new_id) + write_file file, render_subscription_file(data) +end + +Given /^une nouvelle adhésion de (\w+)$/ do |name| + data = { 'name' => name, + 'address' => "At #{name}", + 'email' => "#{name.downcase}@example.org", + 'membership_fee_paid_on' => Time.now.strftime('%Y-%m-%d') + } + create_dir 'Membres' + file = subscription_filename_for_id(new_id) + write_file file, render_subscription_file(data) +end + When /^j'ajoute une fiche correcte pour une nouvelle adhésion$/ do @file = subscription_filename_for_id(new_id) write_file @file, render_subscription_file(EXTRA_SUBSCRIPTION) @@ -7,3 +43,69 @@ When /^j'ajoute une fiche vide$/ do @file = subscription_filename_for_id(new_id) write_file @file, '' end + +When /^j'ajoute une fiche sans YAML$/ do + @file = subscription_filename_for_id(new_id) + write_file @file, <<-EOF.gsub(/^ /, '') + Ceci est une fiche sans YAML. + EOF +end + +When /^j'ajoute une fiche avec du mauvais YAML$/ do + @file = subscription_filename_for_id(new_id) + write_file @file, <<-EOF.gsub(/^ /, '') + --- + [This is missing a closing bracket + --- + EOF +end + +When /^j'ajoute une fiche sans email$/ do + @file = subscription_filename_for_id(new_id) + write_file @file, <<-EOF.gsub(/^ /, '') + --- + name: J. Example + address: | + 21 Jump Street + 42000 Synthé + membership_fee_paid_on: 2013-02-20 + --- + EOF +end + +When /^j'ajoute une fiche sans nom$/ do + @file = subscription_filename_for_id(new_id) + write_file @file, <<-EOF.gsub(/^ /, '') + --- + email: joe@example.org + address: | + 21 Jump Street + 42000 Synthé + membership_fee_paid_on: 2013-02-20 + --- + EOF +end + +When /^j'ajoute une fiche avec comme date de cotisation "([^"]*)"$/ do |date| + @file = subscription_filename_for_id(new_id) + write_file @file, <<-EOF.gsub(/^ /, '') + --- + name: J. Example + email: joe@example.org + address: | + 21 Jump Street + 42000 Synthé + membership_fee_paid_on: #{date} + --- + EOF +end + +When /^je supprime le nom sur une fiche existante$/ do + @file = subscription_filename_for_id(1) + run_simple "sed -e '/^name:/d' -i #{@file}" +end + +When /^j'ajoute un fichier hors de la base des adhérents$/ do + @file = 'test' + write_file @file, 'Test content.' +end