├── app ├── views │ ├── admin │ │ └── registrations │ │ │ ├── index.html.erb │ │ │ ├── _registrations.html.erb │ │ │ ├── _records.html.erb │ │ │ ├── show.html.erb │ │ │ ├── _actions.html.erb │ │ │ └── _registration.html.erb │ └── registration_mailer │ │ ├── rejected_confirmation.html.erb │ │ ├── confirmation.html.erb │ │ ├── notification.html.erb │ │ └── approved_confirmation.html.erb ├── controllers │ ├── registrations_controller.rb │ └── admin │ │ └── registrations_controller.rb ├── models │ └── registration.rb └── mailers │ └── registration_mailer.rb ├── lib ├── generators │ └── refinerycms_registrations_generator.rb ├── tasks │ └── registrations.rake └── refinerycms-registrations.rb ├── db ├── seeds │ └── registrations.rb └── migrate │ └── create_registrations.rb ├── readme.md ├── features ├── support │ └── paths.rb ├── new_registration.feature ├── manage_registrations.feature └── step_definitions │ └── registration_steps.rb ├── config ├── routes.rb └── locales │ ├── en.yml │ └── sk.yml ├── refinerycms-registrations.gemspec └── spec └── models └── registration_spec.rb /app/views/admin/registrations/index.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <%= render :partial => 'records' %> 3 |
4 | -------------------------------------------------------------------------------- /lib/generators/refinerycms_registrations_generator.rb: -------------------------------------------------------------------------------- 1 | class RefinerycmsRegistrations < Refinery::Generators::EngineInstaller 2 | 3 | source_root File.expand_path('../../../', __FILE__) 4 | engine_name "registrations" 5 | 6 | end 7 | -------------------------------------------------------------------------------- /app/views/registration_mailer/rejected_confirmation.html.erb: -------------------------------------------------------------------------------- 1 | Ľutujeme, 2 | tvoja registrácia za člena Progressbar Hackerspace bola zamietnutá. 3 | 4 | S pozdravom, 5 | 6 | Progressbar tím 7 | 8 | info@progressbar.sk 9 | https://www.progressbar.sk -------------------------------------------------------------------------------- /app/views/registration_mailer/confirmation.html.erb: -------------------------------------------------------------------------------- 1 | Ďakujeme za registráciu. 2 | 3 | Tvoja registrácia bude spracovaná v krátkom čase a o výsledku budeš informovaný e-mailom. 4 | 5 | S pozdravom, 6 | 7 | Progressbar tím 8 | 9 | info@progressbar.sk 10 | https://www.progressbar.sk -------------------------------------------------------------------------------- /db/seeds/registrations.rb: -------------------------------------------------------------------------------- 1 | if defined?(User) 2 | User.all.each do |user| 3 | if user.has_role?(:superuser) && user.plugins.where(:name => 'registrations').blank? 4 | user.plugins.create(:name => 'registrations', 5 | :position => (user.plugins.maximum(:position) || -1) +1) 6 | end 7 | end 8 | end -------------------------------------------------------------------------------- /lib/tasks/registrations.rake: -------------------------------------------------------------------------------- 1 | namespace :refinery do 2 | 3 | namespace :registrations do 4 | 5 | # call this task my running: rake refinery:registrations:my_task 6 | # desc "Description of my task below" 7 | # task :my_task => :environment do 8 | # # add your logic here 9 | # end 10 | 11 | end 12 | 13 | end -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Registrations engine for Refinery CMS. 2 | 3 | ## How to build this engine as a gem 4 | 5 | cd vendor/engines/registrations 6 | gem build refinerycms-registrations.gemspec 7 | gem install refinerycms-registrations.gem 8 | 9 | # Sign up for a http://rubygems.org/ account and publish the gem 10 | gem push refinerycms-registrations.gem -------------------------------------------------------------------------------- /app/views/admin/registrations/_registrations.html.erb: -------------------------------------------------------------------------------- 1 | <%= will_paginate @registrations %> 2 | <% group_by_date(@registrations).each do |container| %> 3 |

<%= l((registration_group = container.last).first.created_at, :format => :short) %>

4 | 7 | <% end %> 8 | <%= will_paginate @registrations %> -------------------------------------------------------------------------------- /app/views/registration_mailer/notification.html.erb: -------------------------------------------------------------------------------- 1 | Ahoj, 2 | nová registrácia: 3 | 4 | --- registration_start --- 5 | 6 | Username: <%= @registration.username %> 7 | E-mail: <%= @registration.email %> 8 | Personal info: 9 | <%= @registration.personal_info %> 10 | 11 | --- registration_ends --- 12 | 13 | 14 | S pozdravom, 15 | 16 | Progressbar tím 17 | 18 | info@progressbar.sk 19 | https://www.progressbar.sk -------------------------------------------------------------------------------- /features/support/paths.rb: -------------------------------------------------------------------------------- 1 | module NavigationHelpers 2 | module Refinery 3 | module Registrations 4 | def path_to(page_name) 5 | case page_name 6 | when /the list of registrations/ 7 | admin_registrations_path 8 | 9 | when /the new registration form/ 10 | new_admin_registration_path 11 | else 12 | nil 13 | end 14 | end 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /app/views/registration_mailer/approved_confirmation.html.erb: -------------------------------------------------------------------------------- 1 | Gratulujeme! 2 | Tvoja registrácia za člena Progressbar Hackerspace bola schválená. 3 | 4 | Identifikačné údaje: 5 | 6 | Username: <%= @user.username %> 7 | E-mail: <%= @user.email %> 8 | UID (variabilný symbol pri platbe členského): <%= @user.progressbar_uid.to_s %> 9 | Nastavenie hesla: <%= @new_password_url %> 10 | 11 | S pozdravom, 12 | 13 | Progressbar tím 14 | 15 | info@progressbar.sk 16 | https://www.progressbar.sk -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | ::Refinery::Application.routes.draw do 2 | 3 | resources :registrations, :only => [:index, :create] 4 | 5 | scope(:path => 'refinery', :as => 'admin', :module => 'admin') do 6 | resources :registrations, :only => [:index, :show, :destroy, :accept, :reject] do 7 | collection do 8 | get :spam 9 | get :approved 10 | get :rejected 11 | end 12 | member do 13 | get :toggle_spam 14 | get :approved 15 | get :rejected 16 | end 17 | end 18 | end 19 | end -------------------------------------------------------------------------------- /lib/refinerycms-registrations.rb: -------------------------------------------------------------------------------- 1 | require 'refinerycms-base' 2 | 3 | module Refinery 4 | module Registrations 5 | class Engine < Rails::Engine 6 | config.to_prepare do 7 | require 'filters_spam' 8 | end 9 | 10 | config.after_initialize do 11 | Refinery::Plugin.register do |plugin| 12 | plugin.name = "registrations" 13 | plugin.activity = { 14 | :class => Registration, 15 | :title => 'username' 16 | } 17 | end 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /refinerycms-registrations.gemspec: -------------------------------------------------------------------------------- 1 | Gem::Specification.new do |s| 2 | s.platform = Gem::Platform::RUBY 3 | s.authors = 'nospam.keram@gmail.com' 4 | s.name = 'refinerycms-registrations' 5 | s.version = '1.0' 6 | s.description = 'Ruby on Rails Registrations engine for Refinery CMS' 7 | s.date = '2011-07-24' 8 | s.summary = 'Registrations engine for Refinery CMS' 9 | s.require_paths = %w(lib) 10 | s.files = Dir['lib/**/*', 'config/**/*', 'app/**/*'] 11 | end 12 | -------------------------------------------------------------------------------- /features/new_registration.feature: -------------------------------------------------------------------------------- 1 | @registrations 2 | Feature: Registration 3 | In order to be member 4 | As an visitor 5 | I want to create an registration 6 | 7 | Background: 8 | Given I am a visitor 9 | And I have no registration 10 | And I have a page titled "Join us" with a custom url "/join-us" 11 | And I have a page titled "Thank You" with a custom url "/join-us/thank-you" 12 | 13 | Scenario: Join us page 14 | When I go to the join us page 15 | Then I should see "Name" 16 | And I should see "E-mail" 17 | And I should see "Personal info" 18 | -------------------------------------------------------------------------------- /app/views/admin/registrations/_records.html.erb: -------------------------------------------------------------------------------- 1 | <% if searching? %> 2 |

<%= t('results_for', :scope => 'shared.admin.search', :query => params[:search]) %>

3 | <% end %> 4 | <% if @registrations.any? %> 5 |
6 | <%= render :partial => 'registrations' %> 7 |
8 | <% else %> 9 |

10 | <% unless searching? %> 11 | 12 | <%= t(".no_#{action_name == 'index' ? 'new' : action_name}_registrations") %> 13 | 14 | <% else %> 15 | <%= t('no_results', :scope => 'shared.admin.search') %> 16 | <% end %> 17 |

18 | <% end %> -------------------------------------------------------------------------------- /app/views/admin/registrations/show.html.erb: -------------------------------------------------------------------------------- 1 | <% content_for :body_content_left do %> 2 |
3 |

Username

4 |

5 | <%=raw @registration.username %> 6 |

7 |
8 |
9 |

Email

10 |

11 | <%=raw @registration.email %> 12 |

13 |
14 |
15 |

Personal Info

16 |

17 | <%=raw @registration.personal_info %> 18 |

19 |
20 | <% end %> 21 | 22 | <%= render :partial => "/shared/content_page" %> 23 | -------------------------------------------------------------------------------- /spec/models/registration_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Registration do 4 | 5 | def reset_registration(options = {}) 6 | @valid_attributes = { 7 | :id => 1, 8 | :username => "RSpec is great for testing too" 9 | } 10 | 11 | @registration.destroy! if @registration 12 | @registration = Registration.create!(@valid_attributes.update(options)) 13 | end 14 | 15 | before(:each) do 16 | reset_registration 17 | end 18 | 19 | context "validations" do 20 | 21 | it "rejects empty username" do 22 | Registration.new(@valid_attributes.merge(:username => "")).should_not be_valid 23 | end 24 | 25 | it "rejects non unique username" do 26 | # as one gets created before each spec by reset_registration 27 | Registration.new(@valid_attributes).should_not be_valid 28 | end 29 | 30 | end 31 | 32 | end -------------------------------------------------------------------------------- /features/manage_registrations.feature: -------------------------------------------------------------------------------- 1 | @registrations 2 | Feature: Registrations 3 | In order to have registrations on my website 4 | As an administrator 5 | I want to manage registrations 6 | 7 | Background: 8 | Given I am a logged in refinery user 9 | And I have no registrations 10 | 11 | @registrations-list @list 12 | Scenario: Registrations List 13 | Given I have registrations titled UniqueTitleOne, UniqueTitleTwo 14 | When I go to the list of registrations 15 | Then I should see "UniqueTitleOne" 16 | And I should see "UniqueTitleTwo" 17 | 18 | 19 | # 20 | #When /^I go to the list of registrations$/ do 21 | # pending # express the regexp above with the code you wish you had 22 | #end 23 | # 24 | #Then /^I should see "([^"]*)"$/ do |arg1| 25 | # pending # express the regexp above with the code you wish you had 26 | #end 27 | # 28 | #When /^I follow "([^"]*)"$/ do |arg1| 29 | # pending # express the regexp above with the code you wish you had 30 | #end -------------------------------------------------------------------------------- /db/migrate/create_registrations.rb: -------------------------------------------------------------------------------- 1 | class CreateRegistrations < ActiveRecord::Migration 2 | 3 | def self.up 4 | # in devel 5 | drop_table :registrations if ::Registration.table_exists? && 1 == 1 6 | 7 | create_table :registrations do |t| 8 | t.string :username, :null => false 9 | t.string :email, :null => false 10 | t.text :personal_info, :null => false 11 | t.string :state, :null => false, :default => 'unmoderated' 12 | 13 | t.integer :position 14 | t.boolean :spam, :default => false 15 | 16 | t.timestamps 17 | end 18 | 19 | add_index :registrations, :id 20 | add_index :registrations, :email 21 | 22 | load(Rails.root.join('db', 'seeds', 'registrations.rb')) 23 | end 24 | 25 | def self.down 26 | if defined?(UserPlugin) 27 | UserPlugin.destroy_all({:name => "registrations"}) 28 | end 29 | 30 | if defined?(Page) 31 | Page.delete_all({:link_url => "/registrations"}) 32 | end 33 | 34 | drop_table :registrations 35 | end 36 | 37 | end 38 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | shared: 3 | admin: 4 | image_picker: 5 | image: image 6 | plugins: 7 | registrations: 8 | title: Registrations 9 | admin: 10 | registrations: 11 | actions: 12 | create_new: Add New Registration 13 | reorder: Reorder Registrations 14 | reorder_done: Done Reordering Registrations 15 | records: 16 | title: Registrations 17 | sorry_no_results: Sorry! There are no results found. 18 | no_items_yet: There are no Registrations yet. Click "Add New Registration" to add your first registration. 19 | registration: 20 | view_live_html: View this registration live
(opens in a new window) 21 | edit: Edit this registration 22 | delete: Remove this registration forever 23 | registrations: 24 | show: 25 | other: Other Registrations 26 | registration_was_sent_successfully: 'Registrácia bola úspešne odoslaná' 27 | problems_on_registration: 'There was an error delivering registration' 28 | registration_approved: Registration approved 29 | registration_rejected: Registration rejected 30 | registration_notification: Registration notification 31 | -------------------------------------------------------------------------------- /config/locales/sk.yml: -------------------------------------------------------------------------------- 1 | en: 2 | shared: 3 | admin: 4 | image_picker: 5 | image: image 6 | plugins: 7 | registrations: 8 | title: Registrations 9 | admin: 10 | registrations: 11 | actions: 12 | create_new: Add New Registration 13 | reorder: Reorder Registrations 14 | reorder_done: Done Reordering Registrations 15 | records: 16 | title: Registrations 17 | sorry_no_results: Sorry! There are no results found. 18 | no_items_yet: There are no Registrations yet. Click "Add New Registration" to add your first registration. 19 | registration: 20 | view_live_html: View this registration live
(opens in a new window) 21 | edit: Edit this registration 22 | delete: Remove this registration forever 23 | registrations: 24 | show: 25 | other: Other Registrations 26 | registration_was_sent_successfully: 'Registrácia bola úspešne odoslaná' 27 | problems_on_registration: 'There was an error delivering registration' 28 | registration_approved: Registration approved 29 | registration_rejected: Registration rejected 30 | registration_notification: Registration notification 31 | -------------------------------------------------------------------------------- /app/views/admin/registrations/_actions.html.erb: -------------------------------------------------------------------------------- 1 | 28 | 29 | -------------------------------------------------------------------------------- /app/controllers/registrations_controller.rb: -------------------------------------------------------------------------------- 1 | class RegistrationsController < ApplicationController 2 | 3 | before_filter :default_pages, :find_page, :set_form 4 | 5 | def index 6 | render 'pages/join' 7 | end 8 | 9 | def create 10 | if @registration.valid? && @registration.save 11 | flash[:success] = t('.registration_was_sent_successfully') 12 | if @registration.ham? 13 | begin 14 | RegistrationMailer.notification(@registration, request).deliver 15 | rescue 16 | logger.warn "There was an error delivering an registration notification.\n#{$!}\n" 17 | end 18 | 19 | begin 20 | RegistrationMailer.confirmation(@registration, request).deliver 21 | rescue 22 | logger.warn "There was an error delivering an registration confirmation:\n#{$!}\n" 23 | end 24 | end 25 | 26 | redirect_to url_for(@page) 27 | else 28 | flash[:error] = t('.problems_on_registration') 29 | render 'pages/join' 30 | end 31 | end 32 | 33 | protected 34 | 35 | def find_page 36 | @page = @join_us_page 37 | end 38 | 39 | def set_form 40 | @registration = Registration.new(params[:registration]) 41 | end 42 | 43 | end 44 | -------------------------------------------------------------------------------- /app/models/registration.rb: -------------------------------------------------------------------------------- 1 | class Registration < ActiveRecord::Base 2 | 3 | acts_as_indexed :fields => [:username, :email, :personal_info, :state] 4 | 5 | validates :username, :presence => true, :length => { :in => 6..20 } 6 | validates :email, :presence => true, :uniqueness => true, :length => { :in => 6..42 } 7 | validates :personal_info, :presence => true, :length => { :in => 6..250 } 8 | validates :state, :presence => true, :format => { :with => /unmoderated|approved|rejected/ } 9 | 10 | filters_spam :message_field => :personal_info, 11 | :email_field => :email, 12 | :author_field => :username, 13 | :extra_spam_words => %w() 14 | 15 | scope :unmoderated, :conditions => {:state => 'unmoderated'} 16 | scope :approved, :conditions => {:state => 'approved'} 17 | scope :rejected, :conditions => {:state => 'rejected'} 18 | 19 | def approve! 20 | self.update_attribute(:state, 'approved') 21 | end 22 | 23 | def reject! 24 | self.update_attribute(:state, 'rejected') 25 | end 26 | 27 | def rejected? 28 | self.state == 'rejected' 29 | end 30 | 31 | def approved? 32 | self.state == 'approved' 33 | end 34 | 35 | def unmoderated? 36 | self.state == 'unmoderated' 37 | end 38 | 39 | def self.latest(number = 7, include_spam = false) 40 | include_spam ? limit(number) : ham.limit(number) 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /app/views/admin/registrations/_registration.html.erb: -------------------------------------------------------------------------------- 1 |
  • 2 | 3 | <%= link_to "#{registration.username}, #{registration.email}", admin_registration_url(registration), 4 | :title => t('.read_registration') -%> 5 |   6 | 7 | 8 | <% if registration.spam? %> 9 | <%= link_to refinery_icon_tag('email.png'), toggle_spam_admin_registration_url(registration), 10 | :title => t('.mark_as_ham') -%> 11 | <% else %> 12 | <%= link_to refinery_icon_tag('bin_closed.png'), toggle_spam_admin_registration_url(registration), 13 | :title => t('.mark_as_spam') -%> 14 | <% end %> 15 | <%= link_to refinery_icon_tag("delete.png"), admin_registration_path(registration), 16 | :class => "cancel confirm-delete", 17 | :title => t('.delete'), 18 | :confirm => t('message', :scope => 'shared.admin.delete', :title => registration.username), 19 | :method => :delete %> 20 | 21 | <%= link_to refinery_icon_tag("cross.png"), 22 | rejected_admin_registration_path(registration), 23 | :title => t('.reject') unless registration.rejected? %> 24 | <%= link_to refinery_icon_tag("tick.png"), 25 | approved_admin_registration_path(registration), 26 | :title => t('.approve') unless registration.approved? %> 27 | 28 |
  • 29 | -------------------------------------------------------------------------------- /app/mailers/registration_mailer.rb: -------------------------------------------------------------------------------- 1 | class RegistrationMailer < ActionMailer::Base 2 | 3 | def confirmation(registration, request) 4 | subject "#{RefinerySetting.find_or_set(:site_name, 'Progressbar Hackerspace')} - registration" 5 | recipients registration.email 6 | from "\"#{RefinerySetting[:site_name]}\" " 7 | sent_on Time.now 8 | @registration = registration 9 | end 10 | 11 | def approved_confirmation(registration, user, request) 12 | subject "#{RefinerySetting.find_or_set(:site_name, 'Progressbar Hackerspace')} - #{t('.registration_approved')}" 13 | recipients registration.email 14 | from "\"#{RefinerySetting[:site_name]}\" " 15 | sent_on Time.now 16 | @user = user 17 | @new_password_url = edit_user_password_url(:host => request.host_with_port, 18 | :reset_password_token => @user.reset_password_token) 19 | @registration = registration 20 | end 21 | 22 | def rejected_confirmation(registration, request) 23 | subject "#{RefinerySetting.find_or_set(:site_name, 'Progressbar Hackerspace')} - #{t('.registration_rejected')}" 24 | recipients registration.email 25 | from "\"#{RefinerySetting[:site_name]}\" " 26 | sent_on Time.now 27 | @registration = registration 28 | end 29 | 30 | def notification(registration, request) 31 | subject "#{RefinerySetting.find_or_set(:site_name, 'Progressbar Hackerspace')} - #{t('.registration_notification')}" 32 | recipients RefinerySetting.find_or_set(:registration_notification_recipients, RefinerySetting.find_or_set(:inquiry_notification_recipients, 'info@progressbar.sk')) 33 | from "\"#{RefinerySetting[:site_name]}\" " 34 | sent_on Time.now 35 | @registration = registration 36 | end 37 | 38 | end 39 | -------------------------------------------------------------------------------- /app/controllers/admin/registrations_controller.rb: -------------------------------------------------------------------------------- 1 | module Admin 2 | class RegistrationsController < Admin::BaseController 3 | 4 | crudify :registration, 5 | :title_attribute => 'username', :xhr_paging => true 6 | 7 | helper_method :group_by_date 8 | 9 | before_filter :find_all_ham, :only => [:index, :approved, :rejected] 10 | before_filter :find_all_spam, :only => [:spam] 11 | before_filter :get_spam_count, :only => [:index, :spam, :approved, :rejected] 12 | 13 | def index 14 | @registrations = @registrations.unmoderated 15 | @registrations = @registrations.with_query(params[:search]) if searching? 16 | @registrations = @registrations.paginate({:page => params[:page]}) 17 | end 18 | 19 | def approved 20 | unless params[:id].present? 21 | @registrations = @registrations.approved 22 | @registrations = @registrations.paginate({:page => params[:page]}) 23 | render :action => 'index' 24 | else 25 | @registration = Registration.find(params[:id]) 26 | password = (0...20).map{ ('a'..'z').to_a[rand(26)] }.join 27 | 28 | u = User.create(:username => @registration.username, 29 | :email => @registration.email, 30 | :password => password, 31 | :password_confirmation => password) 32 | 33 | if u.valid? 34 | begin 35 | last_user = User.order('progressbar_uid ASC').limit(1).last 36 | u.add_role(:member) 37 | u.add_role(:refinery) 38 | u.plugins = ['fees'] 39 | u.progressbar_uid = last_user.nil? ? u.id : last_user.progressbar_uid.to_i + 42 40 | u.send(:generate_reset_password_token!) 41 | u.save 42 | @registration.approve! 43 | RegistrationMailer.approved_confirmation(@registration, u, request).deliver 44 | rescue 45 | logger.warn "There was an error delivering an approved registration confirmation.\n#{$!}\n" 46 | end 47 | else 48 | puts "#{@registration.email} - #{u.errors.to_s}" 49 | end 50 | 51 | flash[:notice] = t('approved', :scope => 'admin.registration', :author => @registration.username) 52 | redirect_to :action => 'index' 53 | end 54 | end 55 | 56 | def rejected 57 | unless params[:id].present? 58 | @registrations = @registrations.rejected 59 | @registrations = @registrations.paginate({:page => params[:page]}) 60 | render :action => 'index' 61 | else 62 | begin 63 | @registration = Registration.find(params[:id]) 64 | @registration.reject! 65 | RegistrationMailer.rejected_confirmation(@registration, request).deliver 66 | rescue 67 | logger.warn "There was an error delivering an rejected registration confirmation.\n#{$!}\n" 68 | end 69 | flash[:notice] = t('rejected', :scope => 'admin.registration', :author => @registration.username) 70 | redirect_to :action => 'index' 71 | end 72 | end 73 | 74 | def spam 75 | self.index 76 | render :action => 'index' 77 | end 78 | 79 | def toggle_spam 80 | find_registration 81 | @registration.toggle!(:spam) 82 | 83 | redirect_to :back 84 | end 85 | 86 | protected 87 | 88 | def find_all_ham 89 | @registrations = Registration.ham 90 | end 91 | 92 | def find_all_spam 93 | @registrations = Registration.spam 94 | end 95 | 96 | def get_spam_count 97 | @spam_count = Registration.count(:conditions => {:spam => true}) 98 | end 99 | 100 | end 101 | end -------------------------------------------------------------------------------- /features/step_definitions/registration_steps.rb: -------------------------------------------------------------------------------- 1 | Given /^I have no registrations$/ do 2 | Registration.delete_all 3 | end 4 | 5 | Given /^I (only )?have registrations titled "?([^\"]*)"?$/ do |only, titles| 6 | Registration.delete_all if only 7 | titles.split(', ').each do |title| 8 | Registration.create(:username => title) 9 | end 10 | end 11 | 12 | Then /^I should have ([0-9]+) registrations?$/ do |count| 13 | Registration.count.should == count.to_i 14 | end 15 | 16 | ### 17 | # new registration 18 | ### 19 | 20 | Given /^I am a visitor$/ do 21 | pending # express the regexp above with the code you wish you had 22 | end 23 | 24 | Given /^I have no registration$/ do 25 | pending # express the regexp above with the code you wish you had 26 | end 27 | 28 | Given /^I have a page titled "([^"]*)" with a custom url "([^"]*)"$/ do |arg1, arg2| 29 | pending # express the regexp above with the code you wish you had 30 | end 31 | 32 | When /^I go to the join us page$/ do 33 | pending # express the regexp above with the code you wish you had 34 | end 35 | 36 | Then /^I should see "([^"]*)"$/ do |arg1| 37 | pending # express the regexp above with the code you wish you had 38 | end 39 | 40 | 41 | # 42 | #Given /^I am a logged in refinery user$/ do 43 | # pending # express the regexp above with the code you wish you had 44 | #end 45 | # 46 | #When /^I go to the list of registrations$/ do 47 | # pending # express the regexp above with the code you wish you had 48 | #end 49 | # 50 | #Then /^I should see "([^"]*)"$/ do |arg1| 51 | # pending # express the regexp above with the code you wish you had 52 | #end 53 | # 54 | #When /^I follow "([^"]*)"$/ do |arg1| 55 | # pending # express the regexp above with the code you wish you had 56 | #end 57 | # 58 | #When /^I fill in "([^"]*)" with "([^"]*)"$/ do |arg1, arg2| 59 | # pending # express the regexp above with the code you wish you had 60 | #end 61 | # 62 | #When /^I press "([^"]*)"$/ do |arg1| 63 | # pending # express the regexp above with the code you wish you had 64 | #end 65 | 66 | # 67 | #When /^I follow "([^"]*)" within "([^"]*)"$/ do |arg1, arg2| 68 | # pending # express the regexp above with the code you wish you had 69 | #end 70 | # 71 | #Then /^I fill in "([^"]*)" with "([^"]*)"$/ do |arg1, arg2| 72 | # pending # express the regexp above with the code you wish you had 73 | #end 74 | # 75 | #Then /^I press "([^"]*)"$/ do |arg1| 76 | # pending # express the regexp above with the code you wish you had 77 | #end 78 | # 79 | #Then /^I should be on the list of registrations$/ do 80 | # pending # express the regexp above with the code you wish you had 81 | #end 82 | # 83 | #Then /^I should not see "([^"]*)"$/ do |arg1| 84 | # pending # express the regexp above with the code you wish you had 85 | #end 86 | # 87 | #Given /^I only have (\d+) new registration titled UniqueTitleOne$/ do |arg1| 88 | # pending # express the regexp above with the code you wish you had 89 | #end 90 | # 91 | #Then /^I should have (\d+) accepted registrations$/ do |arg1| 92 | # pending # express the regexp above with the code you wish you had 93 | #end 94 | # 95 | #Then /^I should have (\d+) rejected registrations$/ do |arg1| 96 | # pending # express the regexp above with the code you wish you had 97 | #end 98 | 99 | # 100 | #---- 101 | # 102 | # @registrations-valid @valid 103 | # Scenario: Create Valid Registration 104 | # When I go to the list of registrations 105 | # And I follow "Add New Registration" 106 | # And I fill in "Username" with "This is a test of the first string field" 107 | # And I press "Save" 108 | # Then I should see "'This is a test of the first string field' was successfully added." 109 | # And I should have 1 registration 110 | # 111 | # @registrations-invalid @invalid 112 | # Scenario: Create Invalid Registration (without username) 113 | # When I go to the list of registrations 114 | # And I follow "Add New Registration" 115 | # And I press "Save" 116 | # Then I should see "Username can't be blank" 117 | # And I should have 0 registrations 118 | # 119 | # @registrations-edit @edit 120 | # Scenario: Edit Existing Registration 121 | # Given I have registrations titled "A username" 122 | # When I go to the list of registrations 123 | # And I follow "Edit this registration" within ".actions" 124 | # Then I fill in "Username" with "A different username" 125 | # And I press "Save" 126 | # Then I should see "'A different username' was successfully updated." 127 | # And I should be on the list of registrations 128 | # And I should not see "A username" 129 | # 130 | # @registrations-duplicate @duplicate 131 | # Scenario: Create Duplicate Registration 132 | # Given I only have registrations titled UniqueTitleOne, UniqueTitleTwo 133 | # When I go to the list of registrations 134 | # And I follow "Add New Registration" 135 | # And I fill in "Username" with "UniqueTitleTwo" 136 | # And I press "Save" 137 | # Then I should see "There were problems" 138 | # And I should have 2 registrations 139 | # 140 | # @registrations-accept @accept 141 | # Scenario: Accept Registration 142 | # Given I only have 1 new registration titled UniqueTitleOne 143 | # When I go to the list of registrations 144 | # And I follow "Accept this registration" 145 | # Then I should see "'UniqueTitleOne' was successfully accepted." 146 | # And I should have 1 accepted registrations 147 | # 148 | # @registrations-reject @reject 149 | # Scenario: Reject Registration 150 | # Given I only have registrations titled UniqueTitleOne 151 | # When I go to the list of registrations 152 | # And I follow "Reject this registration" 153 | # Then I should see "'UniqueTitleOne' was rejected." 154 | # And I should have 1 rejected registrations 155 | --------------------------------------------------------------------------------