From 1e33360cc6596fcae184ea88f45d3b9f01359280 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Fri, 28 Jun 2013 20:35:32 +0200 Subject: [PATCH] petitions --- app/assets/stylesheets/application.css.scss | 1 + app/controllers/admin/petitions_controller.rb | 64 +++++++++++++++++++ app/controllers/petitions_controller.rb | 50 +++++++++++++++ app/controllers/survey_sets_controller.rb | 10 +++ app/mailers/petition_mails.rb | 19 ++++++ app/models/petition.rb | 14 ++++ app/models/petition_signator.rb | 19 ++++++ app/views/admin/petitions/_form.haml | 28 ++++++++ app/views/admin/petitions/edit.html.haml | 6 ++ app/views/admin/petitions/index.html.haml | 25 ++++++++ app/views/admin/petitions/new.html.haml | 6 ++ app/views/admin/petitions/show.html.haml | 39 +++++++++++ app/views/layouts/admin.html.haml | 3 +- app/views/layouts/application.html.haml | 2 +- app/views/petition_mails/confirmation.haml | 28 ++++++++ app/views/petitions/_answer_set.html.haml | 32 ++++++++++ app/views/petitions/_form.html.haml | 21 ++++++ app/views/petitions/_question_set.html.haml | 31 +++++++++ app/views/petitions/confirm.html.haml | 5 ++ app/views/petitions/create.html.haml | 7 ++ app/views/petitions/show.html.haml | 6 ++ app/views/tiny_urls/edit.html.erb | 6 -- app/views/tiny_urls/edit.html.haml | 6 ++ app/views/tiny_urls/new.html.erb | 5 -- app/views/tiny_urls/new.html.haml | 6 ++ config/routes.rb | 10 ++- db/migrate/20130628153912_create_petitions.rb | 12 ++++ ...0130628154116_create_petition_signators.rb | 20 ++++++ db/schema.rb | 29 ++++++++- test/fixtures/petition_signators.yml | 25 ++++++++ test/fixtures/petitions.yml | 13 ++++ test/unit/petition_signator_test.rb | 7 ++ test/unit/petition_test.rb | 7 ++ 33 files changed, 547 insertions(+), 15 deletions(-) create mode 100644 app/controllers/admin/petitions_controller.rb create mode 100644 app/controllers/petitions_controller.rb create mode 100644 app/mailers/petition_mails.rb create mode 100644 app/models/petition.rb create mode 100644 app/models/petition_signator.rb create mode 100755 app/views/admin/petitions/_form.haml create mode 100644 app/views/admin/petitions/edit.html.haml create mode 100644 app/views/admin/petitions/index.html.haml create mode 100644 app/views/admin/petitions/new.html.haml create mode 100644 app/views/admin/petitions/show.html.haml create mode 100644 app/views/petition_mails/confirmation.haml create mode 100644 app/views/petitions/_answer_set.html.haml create mode 100644 app/views/petitions/_form.html.haml create mode 100644 app/views/petitions/_question_set.html.haml create mode 100644 app/views/petitions/confirm.html.haml create mode 100644 app/views/petitions/create.html.haml create mode 100644 app/views/petitions/show.html.haml delete mode 100644 app/views/tiny_urls/edit.html.erb create mode 100644 app/views/tiny_urls/edit.html.haml delete mode 100644 app/views/tiny_urls/new.html.erb create mode 100644 app/views/tiny_urls/new.html.haml create mode 100644 db/migrate/20130628153912_create_petitions.rb create mode 100644 db/migrate/20130628154116_create_petition_signators.rb create mode 100644 test/fixtures/petition_signators.yml create mode 100644 test/fixtures/petitions.yml create mode 100644 test/unit/petition_signator_test.rb create mode 100644 test/unit/petition_test.rb diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 4bf00ec..03c07dc 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -1,6 +1,7 @@ /* *= require_self + *= require shared/formtastic */ diff --git a/app/controllers/admin/petitions_controller.rb b/app/controllers/admin/petitions_controller.rb new file mode 100644 index 0000000..ab7872d --- /dev/null +++ b/app/controllers/admin/petitions_controller.rb @@ -0,0 +1,64 @@ +# -*- encoding : utf-8 -*- + +class Admin::PetitionsController < ApplicationController + layout "admin" + before_filter :authenticate_admin! + + def index + @petitions = Petition.all + + + end + + def show + @petition = Petition.find(params[:id]) + + end + + def new + @petition = Petition.new + + end + + def edit + @petition = Petition.find(params[:id]) + end + + def create + @petition = Petition.new(params[:petition]) + + + if @petition.save + redirect_to admin_petitions_url, notice: 'La pétition a été crée.' + + else + render action: "new" + + end + + end + + + def update + @petition = Petition.find(params[:id]) + + + if @petition.update_attributes(params[:petition]) + redirect_to admin_petitions_url, notice: 'Les infos sur la pétition ont été mise à jour.' + + else + render action: "edit" + + end + + end + + + def destroy + @petition = Petition.find(params[:id]) + @petition.destroy + + redirect_to admin_petitions_url + + end +end diff --git a/app/controllers/petitions_controller.rb b/app/controllers/petitions_controller.rb new file mode 100644 index 0000000..f5d9c0e --- /dev/null +++ b/app/controllers/petitions_controller.rb @@ -0,0 +1,50 @@ +# -*- encoding : utf-8 -*- + +class PetitionsController < ApplicationController + + before_filter :authenticate_admin! + + def show + @petition = Petition.find_by_slug(params[:id]) + @signator = @petition.signators.new(:country => "France") + @title = "Le Pic Vert - "+@petition.name + end + + def new + @petition = Petition.new + + end + + def edit + @petition = Petition.find(params[:id]) + end + + def create + @signator = PetitionSignator.new(params[:petition_signator]) + + @petition = @signator.petition + @title = "Le Pic Vert - "+@petition.name + + if @signator.save + PetitionMails.confirmation(@signator).deliver + render action: "create" + else + render action: "show" + + end + + end + + + def confirm + @signator = PetitionSignator.find_by_token(params[:id]) + @petition = @signator.petition + @title = "Le Pic Vert - "+@petition.name + @signator.enabled = true + + @signator.save! + + end + + +end diff --git a/app/controllers/survey_sets_controller.rb b/app/controllers/survey_sets_controller.rb index 7177e85..a2a1a0a 100644 --- a/app/controllers/survey_sets_controller.rb +++ b/app/controllers/survey_sets_controller.rb @@ -9,8 +9,11 @@ class SurveySetsController < ApplicationController end def new + @survey = SurveyType.find_by_slug(params[:slug]) @survey_set = @survey.to_survey_set + @title = "Le Pic Vert - Sondage : "+@survey_set.survey_type.name + end def edit @@ -18,7 +21,11 @@ class SurveySetsController < ApplicationController end def create + @survey_set = SurveySet.new(params[:survey_set]) + + @title = "Le Pic Vert - Sondage : "+@survey_set.survey_type.name + if @survey_set.save redirect_to thank_survey_set_path(:slug => @survey_set.survey_type.slug) else @@ -27,10 +34,13 @@ class SurveySetsController < ApplicationController end def show + @survey = SurveyType.find_by_slug(params[:slug]) end def thank + @survey = SurveyType.find_by_slug(params[:slug]) + @title = "Le Pic Vert - Sondage : "+@survey.name end end diff --git a/app/mailers/petition_mails.rb b/app/mailers/petition_mails.rb new file mode 100644 index 0000000..d816d02 --- /dev/null +++ b/app/mailers/petition_mails.rb @@ -0,0 +1,19 @@ +# -*- encoding : utf-8 -*- +class PetitionMails < ActionMailer::Base + layout 'mail' + + default from: "Le Pic Vert " + + def confirmation(signator) + @signator = signator + @email = @signator.email + @title = "Important : pour valider votre signature." + + mail(:to => @email, :from => @from, :subject => @title) + end + + + + + +end diff --git a/app/models/petition.rb b/app/models/petition.rb new file mode 100644 index 0000000..c702469 --- /dev/null +++ b/app/models/petition.rb @@ -0,0 +1,14 @@ +class Petition < ActiveRecord::Base + attr_accessible :description, :enabled, :name, :slug + + has_many :signators, :class_name => "PetitionSignator" + + def signators_number + self.signators.count + end + + def confirmed_signators_number + self.signators.where(:enabled => true).count + end + +end diff --git a/app/models/petition_signator.rb b/app/models/petition_signator.rb new file mode 100644 index 0000000..92133c2 --- /dev/null +++ b/app/models/petition_signator.rb @@ -0,0 +1,19 @@ +class PetitionSignator < ActiveRecord::Base + belongs_to :petition + attr_accessor :email_confirmation + attr_accessible :address, :address2, :city, :enabled, :token, :country, :cp, :email, :email_confirmation, :firstname, :name, :petition_id + + validates :email, :presence => true, :confirmation => true, :uniqueness => { :scope => :petition_id } + + validates :name, :presence => true + validates :firstname, :presence => true + validates :address, :presence => true + validates :cp, :presence => true + validates :city, :presence => true + validates :country, :presence => true + + before_create do + self.token = (Digest::MD5.hexdigest "#{SecureRandom.hex(10)}-#{DateTime.now.to_s}") + end + +end diff --git a/app/views/admin/petitions/_form.haml b/app/views/admin/petitions/_form.haml new file mode 100755 index 0000000..b90f75b --- /dev/null +++ b/app/views/admin/petitions/_form.haml @@ -0,0 +1,28 @@ +=form_for [:admin, @petition] do |f| + =f.submit "sauvegarder", :class => "btn" + %p + Nom : + =f.text_field :name + %p + Permalink : + =f.text_field :slug + + + %p + =f.text_area :description, :class => "redactor_content", :style => "height:600px;width:100%;max-width:100%" + + :javascript + + $('.redactor_content').redactor({ + + fixed: true, + lang: 'fr', + buttons : ['html', '|', 'formatting', '|', 'bold', 'italic', 'deleted','underline','|', 'alignleft', 'aligncenter', 'alignright', 'justify', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'table', 'link', '|','fontcolor', 'backcolor','|', 'horizontalrule'], + + + }); + + + =f.submit "sauvegarder", :class => "btn" + + \ No newline at end of file diff --git a/app/views/admin/petitions/edit.html.haml b/app/views/admin/petitions/edit.html.haml new file mode 100644 index 0000000..91a5f21 --- /dev/null +++ b/app/views/admin/petitions/edit.html.haml @@ -0,0 +1,6 @@ +%h1 Modifier l'url + += render 'form' + += link_to 'Show', @tiny_url += link_to 'Back', tiny_urls_path diff --git a/app/views/admin/petitions/index.html.haml b/app/views/admin/petitions/index.html.haml new file mode 100644 index 0000000..4db7db6 --- /dev/null +++ b/app/views/admin/petitions/index.html.haml @@ -0,0 +1,25 @@ += link_to i(:plus)+' Ajouter une petition', new_admin_petition_path, :class => "btn" +%h1 Liste des petitions en ligne + +%table.stat_table.table.table-striped + %tr + %th Nom + %th Url + %th Nbr sign. + %th + + + + - @petitions.each do |petition| + %tr + %td= petition.name + %td=link_to petition_url(:id => petition.slug),petition_url(:id => petition.slug) + + %td + =petition.confirmed_signators_number + ="("+(petition.signators_number-petition.confirmed_signators_number).to_s+" en attente)" if petition.signators_number-petition.confirmed_signators_number > 0 + %td + = link_to i(:"eye-open"), [:admin, petition] + = link_to i(:pencil), edit_admin_petition_path(petition) + = link_to i(:trash), [:admin, petition], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cette petition ? Les signatures seront également supprimées.' } + diff --git a/app/views/admin/petitions/new.html.haml b/app/views/admin/petitions/new.html.haml new file mode 100644 index 0000000..2f807c2 --- /dev/null +++ b/app/views/admin/petitions/new.html.haml @@ -0,0 +1,6 @@ +%h1 Ajouter une url + += render 'form' + += link_to 'Back', tiny_urls_path + diff --git a/app/views/admin/petitions/show.html.haml b/app/views/admin/petitions/show.html.haml new file mode 100644 index 0000000..0ecd4a1 --- /dev/null +++ b/app/views/admin/petitions/show.html.haml @@ -0,0 +1,39 @@ +%h1=@petition.name +.alert.alert-info + Adresse publique de la pétition : + =link_to petition_url(:id => @petition.slug),petition_url(:id => @petition.slug) +=raw @petition.description + +%hr + + +%h1 + Liste des signataires + +%p + %span.badge.badge-success=@petition.confirmed_signators_number + =raw "- "+raw(content_tag("span", (@petition.signators_number-@petition.confirmed_signators_number).to_s, :class => "badge badge-warning"))+" en attente" if @petition.signators_number-@petition.confirmed_signators_number > 0 +%table.table.table.table-striped.table-bordered + %tr + %th Nom + %th Prénom + %th Adresse + %th Adresse suite + %th Ville + %th Pays + %th Email + %th + + -@petition.signators.each do |signator| + %tr{:class => (signator.enabled ? "success" : "warning")} + %td=signator.name + %td=signator.firstname + %td=signator.address + %td=signator.address2 + %td + =signator.cp + =signator.city + %td=signator.country + %td=signator.email + %td + \ No newline at end of file diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index ef325a6..523b999 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -26,7 +26,7 @@ %li.dropdown %a{:href => "#", :class => "dropdown-toggle", :data => {:toggle => "dropdown"}} - =image_tag (current_admin.file? ? current_admin.file.square.url : ""), :class => "avatar", :style => "height:15px;" + =image_tag (current_admin.file? ? current_admin.file.square.url : ""), :class => "img img-rounded", :style => "height:15px;" =current_admin.firstname =current_admin.name %b.caret @@ -51,6 +51,7 @@ %li=link_to "gestion newsletters", newsletters_path %li.divider %li=link_to "Sondages", admin_surveys_path + %li=link_to "Petitions", admin_petitions_path diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 765dd2e..229327d 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,7 +1,7 @@ !!! %html %head - %title Le Pic Vert - Votre avis sur les sorties du Pic Vert + %title= @title || "Le Pic Vert." = stylesheet_link_tag "application", :media => "all" = javascript_include_tag "application" = csrf_meta_tags diff --git a/app/views/petition_mails/confirmation.haml b/app/views/petition_mails/confirmation.haml new file mode 100644 index 0000000..d1a7ca1 --- /dev/null +++ b/app/views/petition_mails/confirmation.haml @@ -0,0 +1,28 @@ +%p + Bonjour + =@signator.firstname+"," + +%p + Vous venez de signer " + =@signator.petition.name + ='",' + merci pour votre soutient. + +%p + Pour que votre signature soit bien prise en compte, merci de cliquer sur ce lien, où de le copier dans la barre d'adresse de votre navigateur : + +%p{:style => "text-align:center"} + =link_to confirm_petition_url(:id => @signator.token),confirm_petition_url(:id => @signator.token) + +%p + %strong Association Le Pic Vert + %br + 24 place de la Mairie + %br + 38140 Réaumont + +%p + Tel : 04 76 91 34 33 + Site internet : www.lepicvert.asso.fr + Mail : contact@lepicvert.asso.fr + \ No newline at end of file diff --git a/app/views/petitions/_answer_set.html.haml b/app/views/petitions/_answer_set.html.haml new file mode 100644 index 0000000..09028da --- /dev/null +++ b/app/views/petitions/_answer_set.html.haml @@ -0,0 +1,32 @@ + + + + + +.answer_p + + + =f.check_box :is_checked, :class => "checkboxe_#{answer.survey_item.id}" + -checkboxe_class = "checkboxe_#{answer.survey_item.id}" + =f.label :is_checked, answer.label_text + + =f.text_field :content if answer.field_type == 2 + + + + +-if 1 == 2 + %script + = raw '$("input[type=checkbox][class='+checkboxe_class+']").click(function() {' + + = raw 'var bol = $("input[type=checkbox][class='+checkboxe_class+']:checked").length >= 1000;' + = raw '$("input[type=checkbox][class='+checkboxe_class+']").not(":checked").attr("disabled",bol);' + + + + }); + + + + + \ No newline at end of file diff --git a/app/views/petitions/_form.html.haml b/app/views/petitions/_form.html.haml new file mode 100644 index 0000000..aac4306 --- /dev/null +++ b/app/views/petitions/_form.html.haml @@ -0,0 +1,21 @@ +%h2 Ajouter ma signature. +=semantic_form_for @signator, :url => petitions_path, :method => :post do |f| + =f.hidden_field :petition_id + + =f.inputs do + =f.input :name, :label => "Nom :" + =f.input :firstname, :label => "Prénom :" + =f.input :address, :label => "Adresse :" + =f.input :address2, :label => "Adresse (suite) :" + =f.input :cp, :label => "Code postal :" + =f.input :city, :label => "Ville :" + =f.input :country, :label => "Pays :", :as => :string + =f.input :email, :label => "Email :" + =f.input :email_confirmation, :label => "Email (confirmation) :" + + + + %p=f.submit "Envoyer ma signature", :style => "margin-bottom:1em;" + + %p + Attention, afin de valider votre signature il faut absolument cliquer sur le lien de validation que vous allez recevoir dans un mail envoyé à l'adresse email que vous avez indiquée. \ No newline at end of file diff --git a/app/views/petitions/_question_set.html.haml b/app/views/petitions/_question_set.html.haml new file mode 100644 index 0000000..609895a --- /dev/null +++ b/app/views/petitions/_question_set.html.haml @@ -0,0 +1,31 @@ + +.question=item.title + +-if item.questions_type == 1 + .answer_p + =f.radio_button :boolean_content, true + =f.label :boolean_content_true, "oui" + =f.radio_button :boolean_content, false + =f.label :boolean_content_false, "non" + +-elsif item.questions_type == 2 + .answer_p + -if item.text_presentation == 2 + =f.text_area :content, :class => "large" + -else + =f.text_field :content, :class => "large" +-elsif item.questions_type == 3 + = f.fields_for(:answer_sets) do |f| + =f.hidden_field :survey_item_answer_id + =render :partial => "survey_sets/answer_set", :locals => {:f => f, :answer => f.object.survey_item_answer} + +-elsif item.questions_type == 4 + + -item.answers.each do |answer| + .answer_p{:style =>( "display:inline;" if item.display_type == 1)} + =f.radio_button :content, answer.label_text + =f.label :content, answer.label_text, :value => answer.label_text + + + + \ No newline at end of file diff --git a/app/views/petitions/confirm.html.haml b/app/views/petitions/confirm.html.haml new file mode 100644 index 0000000..45a4ee5 --- /dev/null +++ b/app/views/petitions/confirm.html.haml @@ -0,0 +1,5 @@ +%h1 Votre signature a bien été validée ! + +%p Merci d'avoir agi pour la protection de la nature. +%p N'hésitez pas à diffuser le lien pour cette action : +%p{:style => "text-align:center;"}=link_to petition_url(@petition.slug), petition_url(@petition.slug) diff --git a/app/views/petitions/create.html.haml b/app/views/petitions/create.html.haml new file mode 100644 index 0000000..9a83fa5 --- /dev/null +++ b/app/views/petitions/create.html.haml @@ -0,0 +1,7 @@ +%p Merci beaucoup pour votre soutien + +%h1 ... encore une petite étape pour valider votre signature : + +%p Pour valider votre signature, il faut cliquer sur le lien que vous venez de recevoir dans votre boite mail. Sans validation de votre part, votre signature ne sera pas prise en compte. + + diff --git a/app/views/petitions/show.html.haml b/app/views/petitions/show.html.haml new file mode 100644 index 0000000..f7a6ab4 --- /dev/null +++ b/app/views/petitions/show.html.haml @@ -0,0 +1,6 @@ +%h1=@petition.name +=raw @petition.description + +%hr + +=render :partial => "form" \ No newline at end of file diff --git a/app/views/tiny_urls/edit.html.erb b/app/views/tiny_urls/edit.html.erb deleted file mode 100644 index dafcb7a..0000000 --- a/app/views/tiny_urls/edit.html.erb +++ /dev/null @@ -1,6 +0,0 @@ -

Editing tiny_url

- -<%= render 'form' %> - -<%= link_to 'Show', @tiny_url %> | -<%= link_to 'Back', tiny_urls_path %> diff --git a/app/views/tiny_urls/edit.html.haml b/app/views/tiny_urls/edit.html.haml new file mode 100644 index 0000000..91a5f21 --- /dev/null +++ b/app/views/tiny_urls/edit.html.haml @@ -0,0 +1,6 @@ +%h1 Modifier l'url + += render 'form' + += link_to 'Show', @tiny_url += link_to 'Back', tiny_urls_path diff --git a/app/views/tiny_urls/new.html.erb b/app/views/tiny_urls/new.html.erb deleted file mode 100644 index 6c53dc3..0000000 --- a/app/views/tiny_urls/new.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

New tiny_url

- -<%= render 'form' %> - -<%= link_to 'Back', tiny_urls_path %> diff --git a/app/views/tiny_urls/new.html.haml b/app/views/tiny_urls/new.html.haml new file mode 100644 index 0000000..2f807c2 --- /dev/null +++ b/app/views/tiny_urls/new.html.haml @@ -0,0 +1,6 @@ +%h1 Ajouter une url + += render 'form' + += link_to 'Back', tiny_urls_path + diff --git a/config/routes.rb b/config/routes.rb index 533fc80..c13552c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,6 +9,7 @@ Survey::Application.routes.draw do root :to => "dashboard#index" resources :admins resources :surveys + resources :petitions end @@ -83,8 +84,15 @@ Survey::Application.routes.draw do match 'sondages/:slug/merci-de-votre-participation.:f' => 'survey_sets#thank', :as => :thank_survey_set, :f => "html" match 'sondages/:slug.:f' => 'survey_sets#new', :as => :new_survey_set, :f => "html" match 'sondages/:slug/resultats.:f' => 'survey_sets#show', :as => :survey_set, :f => "html" - + match 'petitions/:id.:f' => 'petitions#show', :as => :petition, :f => "html" + + + resources :petitions do + member do + get :confirm + end + end resources :survey_sets do collection do diff --git a/db/migrate/20130628153912_create_petitions.rb b/db/migrate/20130628153912_create_petitions.rb new file mode 100644 index 0000000..f1b78a2 --- /dev/null +++ b/db/migrate/20130628153912_create_petitions.rb @@ -0,0 +1,12 @@ +class CreatePetitions < ActiveRecord::Migration + def change + create_table :petitions do |t| + t.string :name + t.text :description + t.string :slug + t.boolean :enabled + + t.timestamps + end + end +end diff --git a/db/migrate/20130628154116_create_petition_signators.rb b/db/migrate/20130628154116_create_petition_signators.rb new file mode 100644 index 0000000..d99d7c7 --- /dev/null +++ b/db/migrate/20130628154116_create_petition_signators.rb @@ -0,0 +1,20 @@ +class CreatePetitionSignators < ActiveRecord::Migration + def change + create_table :petition_signators do |t| + t.references :petition + t.string :firstname + t.string :name + t.string :address + t.string :address2 + t.string :cp + t.string :city + t.string :country + t.string :email + t.boolean :enabled + t.string :token + + t.timestamps + end + add_index :petition_signators, :petition_id + end +end diff --git a/db/schema.rb b/db/schema.rb index fccc18f..56fd762 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130319095715) do +ActiveRecord::Schema.define(:version => 20130628154116) do create_table "admins", :force => true do |t| t.string "email", :default => "", :null => false @@ -191,6 +191,33 @@ ActiveRecord::Schema.define(:version => 20130319095715) do t.datetime "updated_at" end + create_table "petition_signators", :force => true do |t| + t.integer "petition_id" + t.string "firstname" + t.string "name" + t.string "address" + t.string "address2" + t.string "cp" + t.string "city" + t.string "country" + t.string "email" + t.boolean "enabled" + t.string "token" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "petition_signators", ["petition_id"], :name => "index_petition_signators_on_petition_id" + + create_table "petitions", :force => true do |t| + t.string "name" + t.text "description" + t.string "slug" + t.boolean "enabled" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "question_sets", :force => true do |t| t.integer "survey_item_id" t.integer "survey_set_id" diff --git a/test/fixtures/petition_signators.yml b/test/fixtures/petition_signators.yml new file mode 100644 index 0000000..4ccb5a4 --- /dev/null +++ b/test/fixtures/petition_signators.yml @@ -0,0 +1,25 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + petition: + firstname: MyString + name: MyString + address: MyString + address2: MyString + cp: MyString + city: MyString + country: MyString + email: MyString + confirmed: false + +two: + petition: + firstname: MyString + name: MyString + address: MyString + address2: MyString + cp: MyString + city: MyString + country: MyString + email: MyString + confirmed: false diff --git a/test/fixtures/petitions.yml b/test/fixtures/petitions.yml new file mode 100644 index 0000000..5e911ba --- /dev/null +++ b/test/fixtures/petitions.yml @@ -0,0 +1,13 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + name: MyString + description: MyText + slug: MyString + enabled: false + +two: + name: MyString + description: MyText + slug: MyString + enabled: false diff --git a/test/unit/petition_signator_test.rb b/test/unit/petition_signator_test.rb new file mode 100644 index 0000000..6140ede --- /dev/null +++ b/test/unit/petition_signator_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PetitionSignatorTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/unit/petition_test.rb b/test/unit/petition_test.rb new file mode 100644 index 0000000..8b11723 --- /dev/null +++ b/test/unit/petition_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PetitionTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end