noodall 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/bin/noodall +8 -0
  2. data/lib/noodall/generator.rb +40 -0
  3. data/lib/noodall/templates/Gemfile +23 -0
  4. data/lib/noodall/templates/README +256 -0
  5. data/lib/noodall/templates/Rakefile +7 -0
  6. data/lib/noodall/templates/app/controllers/application_controller.rb +3 -0
  7. data/lib/noodall/templates/app/helpers/application_helper.rb +58 -0
  8. data/lib/noodall/templates/app/mailers/.empty_directory +0 -0
  9. data/lib/noodall/templates/app/models/.empty_directory +0 -0
  10. data/lib/noodall/templates/app/views/layouts/application.html.erb.tt +19 -0
  11. data/lib/noodall/templates/config/application.rb +49 -0
  12. data/lib/noodall/templates/config/boot.rb +13 -0
  13. data/lib/noodall/templates/config/cucumber.yml +8 -0
  14. data/lib/noodall/templates/config/database.yml +11 -0
  15. data/lib/noodall/templates/config/environment.rb +5 -0
  16. data/lib/noodall/templates/config/environments/development.rb.tt +27 -0
  17. data/lib/noodall/templates/config/environments/production.rb.tt +50 -0
  18. data/lib/noodall/templates/config/environments/staging.rb.tt +50 -0
  19. data/lib/noodall/templates/config/environments/test.rb.tt +36 -0
  20. data/lib/noodall/templates/config/initializers/backtrace_silencers.rb +7 -0
  21. data/lib/noodall/templates/config/initializers/devise.rb.tt +143 -0
  22. data/lib/noodall/templates/config/initializers/inflections.rb +10 -0
  23. data/lib/noodall/templates/config/initializers/mime_types.rb +5 -0
  24. data/lib/noodall/templates/config/initializers/mongo_mapper.rb +11 -0
  25. data/lib/noodall/templates/config/initializers/noodall.rb +3 -0
  26. data/lib/noodall/templates/config/initializers/secret_token.rb.tt +7 -0
  27. data/lib/noodall/templates/config/initializers/session_store.rb.tt +8 -0
  28. data/lib/noodall/templates/config/locales/devise.en.yml +39 -0
  29. data/lib/noodall/templates/config/locales/en.yml +5 -0
  30. data/lib/noodall/templates/config/routes.rb +9 -0
  31. data/lib/noodall/templates/config.ru +4 -0
  32. data/lib/noodall/templates/db/seeds.rb +10 -0
  33. data/lib/noodall/templates/doc/README_FOR_APP +2 -0
  34. data/lib/noodall/templates/features/component_slots.feature +15 -0
  35. data/lib/noodall/templates/features/content_templates.feature +22 -0
  36. data/lib/noodall/templates/features/step_definitions/cms_node_steps.rb +84 -0
  37. data/lib/noodall/templates/features/step_definitions/component_steps.rb +46 -0
  38. data/lib/noodall/templates/features/step_definitions/sign_in_steps.rb +48 -0
  39. data/lib/noodall/templates/features/step_definitions/web_steps.rb +219 -0
  40. data/lib/noodall/templates/features/support/env.rb +53 -0
  41. data/lib/noodall/templates/features/support/home_page.rb +4 -0
  42. data/lib/noodall/templates/features/support/paths.rb +35 -0
  43. data/lib/noodall/templates/gitignore +4 -0
  44. data/lib/noodall/templates/public/404.html +26 -0
  45. data/lib/noodall/templates/public/422.html +26 -0
  46. data/lib/noodall/templates/public/500.html +26 -0
  47. data/lib/noodall/templates/public/favicon.ico +0 -0
  48. data/lib/noodall/templates/public/images/rails.png +0 -0
  49. data/lib/noodall/templates/public/index.html +239 -0
  50. data/lib/noodall/templates/public/javascripts/application.js +2 -0
  51. data/lib/noodall/templates/public/javascripts/controls.js +965 -0
  52. data/lib/noodall/templates/public/javascripts/dragdrop.js +974 -0
  53. data/lib/noodall/templates/public/javascripts/effects.js +1123 -0
  54. data/lib/noodall/templates/public/javascripts/prototype.js +6001 -0
  55. data/lib/noodall/templates/public/robots.txt +5 -0
  56. data/lib/noodall/templates/public/stylesheets/.empty_directory +0 -0
  57. data/lib/noodall/templates/script/cucumber +10 -0
  58. data/lib/noodall/templates/script/rails +5 -0
  59. data/lib/noodall/templates/spec/factories/asset.rb +6 -0
  60. data/lib/noodall/templates/spec/factories/home.rb +5 -0
  61. data/lib/noodall/templates/spec/factories/user.rb +15 -0
  62. data/lib/noodall/templates/spec/files/beef.png +0 -0
  63. data/lib/noodall/templates/spec/files/test.pdf +0 -0
  64. data/lib/noodall/version.rb +1 -1
  65. data/noodall.gemspec +4 -3
  66. metadata +91 -12
@@ -0,0 +1,36 @@
1
+ <%= app_const %>.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Log error messages when you accidentally call methods on nil.
11
+ config.whiny_nils = true
12
+
13
+ # Show full error reports and disable caching
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Raise exceptions instead of rendering exception templates
18
+ config.action_dispatch.show_exceptions = false
19
+
20
+ # Disable request forgery protection in test environment
21
+ config.action_controller.allow_forgery_protection = false
22
+
23
+ # Tell Action Mailer not to deliver emails to the real world.
24
+ # The :test delivery method accumulates sent emails in the
25
+ # ActionMailer::Base.deliveries array.
26
+ config.action_mailer.delivery_method = :test
27
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
28
+
29
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
30
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
31
+ # like if you have constraints or database-specific column types
32
+ # config.active_record.schema_format = :sql
33
+
34
+ # Print deprecation notices to the stderr
35
+ config.active_support.deprecation = :stderr
36
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,143 @@
1
+ # Use this hook to configure devise mailer, warden hooks and so forth. The first
2
+ # four configuration values can also be set straight in your models.
3
+ Devise.setup do |config|
4
+ # ==> Mailer Configuration
5
+ # Configure the e-mail address which will be shown in DeviseMailer.
6
+ config.mailer_sender = "please-change-me@config-initializers-devise.com"
7
+
8
+ # Configure the class responsible to send e-mails.
9
+ # config.mailer = "Devise::Mailer"
10
+
11
+ # ==> ORM configuration
12
+ # Load and configure the ORM. Supports :active_record (default) and
13
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
14
+ # available as additional gems.
15
+ require 'devise/orm/mongo_mapper'
16
+
17
+ # ==> Configuration for any authentication mechanism
18
+ # Configure which keys are used when authenticating an user. By default is
19
+ # just :email. You can configure it to use [:username, :subdomain], so for
20
+ # authenticating an user, both parameters are required. Remember that those
21
+ # parameters are used only when authenticating and not when retrieving from
22
+ # session. If you need permissions, you should implement that in a before filter.
23
+ # config.authentication_keys = [ :email ]
24
+
25
+ # Tell if authentication through request.params is enabled. True by default.
26
+ # config.params_authenticatable = true
27
+
28
+ # Tell if authentication through HTTP Basic Auth is enabled. False by default.
29
+ # config.http_authenticatable = false
30
+
31
+ # Set this to true to use Basic Auth for AJAX requests. True by default.
32
+ # config.http_authenticatable_on_xhr = true
33
+
34
+ # The realm used in Http Basic Authentication
35
+ # config.http_authentication_realm = "Application"
36
+
37
+ # ==> Configuration for :database_authenticatable
38
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
39
+ # using other encryptors, it sets how many times you want the password re-encrypted.
40
+ config.stretches = 10
41
+
42
+ # Define which will be the encryption algorithm. Devise also supports encryptors
43
+ # from others authentication tools as :clearance_sha1, :authlogic_sha512 (then
44
+ # you should set stretches above to 20 for default behavior) and :restful_authentication_sha1
45
+ # (then you should set stretches to 10, and copy REST_AUTH_SITE_KEY to pepper)
46
+ config.encryptor = :bcrypt
47
+
48
+ # Setup a pepper to generate the encrypted password.
49
+ config.pepper = <%= ActiveSupport::SecureRandom.hex(64).inspect %>
50
+
51
+ # ==> Configuration for :confirmable
52
+ # The time you want to give your user to confirm his account. During this time
53
+ # he will be able to access your application without confirming. Default is nil.
54
+ # When confirm_within is zero, the user won't be able to sign in without confirming.
55
+ # You can use this to let your user access some features of your application
56
+ # without confirming the account, but blocking it after a certain period
57
+ # (ie 2 days).
58
+ # config.confirm_within = 2.days
59
+
60
+ # ==> Configuration for :rememberable
61
+ # The time the user will be remembered without asking for credentials again.
62
+ # config.remember_for = 2.weeks
63
+
64
+ # If true, a valid remember token can be re-used between multiple browsers.
65
+ # config.remember_across_browsers = true
66
+
67
+ # If true, extends the user's remember period when remembered via cookie.
68
+ # config.extend_remember_period = false
69
+
70
+ # ==> Configuration for :validatable
71
+ # Range for password length
72
+ # config.password_length = 6..20
73
+
74
+ # Regex to use to validate the email address
75
+ # config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
76
+
77
+ # ==> Configuration for :timeoutable
78
+ # The time you want to timeout the user session without activity. After this
79
+ # time the user will be asked for credentials again.
80
+ # config.timeout_in = 10.minutes
81
+
82
+ # ==> Configuration for :lockable
83
+ # Defines which strategy will be used to lock an account.
84
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
85
+ # :none = No lock strategy. You should handle locking by yourself.
86
+ # config.lock_strategy = :failed_attempts
87
+
88
+ # Defines which strategy will be used to unlock an account.
89
+ # :email = Sends an unlock link to the user email
90
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
91
+ # :both = Enables both strategies
92
+ # :none = No unlock strategy. You should handle unlocking by yourself.
93
+ # config.unlock_strategy = :both
94
+
95
+ # Number of authentication tries before locking an account if lock_strategy
96
+ # is failed attempts.
97
+ # config.maximum_attempts = 20
98
+
99
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
100
+ # config.unlock_in = 1.hour
101
+
102
+ # ==> Configuration for :token_authenticatable
103
+ # Defines name of the authentication token params key
104
+ # config.token_authentication_key = :auth_token
105
+
106
+ # ==> Scopes configuration
107
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
108
+ # "users/sessions/new". It's turned off by default because it's slower if you
109
+ # are using only default views.
110
+ # config.scoped_views = true
111
+
112
+ # Configure the default scope given to Warden. By default it's the first
113
+ # devise role declared in your routes.
114
+ # config.default_scope = :user
115
+
116
+ # Configure sign_out behavior.
117
+ # By default sign_out is scoped (i.e. /users/sign_out affects only :user scope).
118
+ # In case of sign_out_all_scopes set to true any logout action will sign out all active scopes.
119
+ # config.sign_out_all_scopes = false
120
+
121
+ # ==> Navigation configuration
122
+ # Lists the formats that should be treated as navigational. Formats like
123
+ # :html, should redirect to the sign in page when the user does not have
124
+ # access, but formats like :xml or :json, should return 401.
125
+ # If you have any extra navigational formats, like :iphone or :mobile, you
126
+ # should add them to the navigational formats lists. Default is [:html]
127
+ # config.navigational_formats = [:html, :iphone]
128
+
129
+ # ==> Warden configuration
130
+ # If you want to use other strategies, that are not (yet) supported by Devise,
131
+ # you can configure them inside the config.warden block. The example below
132
+ # allows you to setup OAuth, using http://github.com/roman/warden_oauth
133
+ #
134
+ # config.warden do |manager|
135
+ # manager.oauth(:twitter) do |twitter|
136
+ # twitter.consumer_secret = <YOUR CONSUMER SECRET>
137
+ # twitter.consumer_key = <YOUR CONSUMER KEY>
138
+ # twitter.options :site => 'http://twitter.com'
139
+ # end
140
+ # manager.default_strategies(:scope => :user).unshift :twitter_oauth
141
+ # end
142
+ end
143
+
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,11 @@
1
+ if ENV['MONGOHQ_URL']
2
+ config = {Rails.env => {'uri' => ENV['MONGOHQ_URL']}}
3
+ else
4
+ config = Rails.configuration.database_configuration
5
+ end
6
+
7
+ MongoMapper.setup(
8
+ config,
9
+ Rails.env,
10
+ { :logger => Rails.logger }
11
+ )
@@ -0,0 +1,3 @@
1
+ require 'noodall/dragonfly'
2
+ Noodall::Node.slots :main, :wide, :small
3
+ Noodall::Node.set_collection_name 'nodes'
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ <%= app_const %>.config.secret_token = '<%= app_secret %>'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ <%= app_const %>.config.session_store :cookie_store, :key => '_<%= app_name %>_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rake db:sessions:create")
8
+ # <%= app_const %>.config.session_store :active_record_store
@@ -0,0 +1,39 @@
1
+ en:
2
+ errors:
3
+ messages:
4
+ not_found: "not found"
5
+ already_confirmed: "was already confirmed"
6
+ not_locked: "was not locked"
7
+
8
+ devise:
9
+ failure:
10
+ unauthenticated: 'You need to sign in or sign up before continuing.'
11
+ unconfirmed: 'You have to confirm your account before continuing.'
12
+ locked: 'Your account is locked.'
13
+ invalid: 'Invalid email or password.'
14
+ invalid_token: 'Invalid authentication token.'
15
+ timeout: 'Your session expired, please sign in again to continue.'
16
+ inactive: 'Your account was not activated yet.'
17
+ sessions:
18
+ signed_in: 'Signed in successfully.'
19
+ signed_out: 'Signed out successfully.'
20
+ passwords:
21
+ send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
22
+ updated: 'Your password was changed successfully. You are now signed in.'
23
+ confirmations:
24
+ send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
25
+ confirmed: 'Your account was successfully confirmed. You are now signed in.'
26
+ registrations:
27
+ signed_up: 'You have signed up successfully. If enabled, a confirmation was sent to your e-mail.'
28
+ updated: 'You updated your account successfully.'
29
+ destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
30
+ unlocks:
31
+ send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
32
+ unlocked: 'Your account was successfully unlocked. You are now signed in.'
33
+ mailer:
34
+ confirmation_instructions:
35
+ subject: 'Confirmation instructions'
36
+ reset_password_instructions:
37
+ subject: 'Reset password instructions'
38
+ unlock_instructions:
39
+ subject: 'Unlock Instructions'
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,9 @@
1
+ <%= app_const %>.routes.draw do
2
+ devise_for :users
3
+ namespace :admin do
4
+ resources :users
5
+ end
6
+ end
7
+
8
+ require 'noodall/routes'
9
+ Noodall::Routes.draw <%= app_const %>
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run <%= app_const %>
@@ -0,0 +1,10 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7
+ # Mayor.create(:name => 'Daley', :city => cities.first)
8
+ #
9
+ User.create!(:name => "Mr Admin", :email => "hello@wearebeef.co.uk", :password => "passw0rd", :password_confirmation => "passw0rd", :groups => ['admin'])
10
+ Home.create!(:title => "Home", :publish => true)
@@ -0,0 +1,2 @@
1
+ Use this README file to introduce your application and point to useful places in the API for learning more.
2
+ Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
@@ -0,0 +1,15 @@
1
+ Feature: Component Slots
2
+ In order that web site editors can add functionality and information to content they will be able to fill slots with components
3
+
4
+ Scenario Outline: Component Slots
5
+ Given a <Template Name> exists
6
+ And I am signed in as a website editor
7
+ When I am editing the <Template Name>
8
+ Then I should be able to place components in <Hero Slots Per Page> hero slots
9
+ And I should be able to place components in <Wide Slots Per Page> wide slots
10
+ And I should be able to place components in <Small Slots Per Page> small slots
11
+
12
+ Examples:
13
+ | Template Name | Hero Slots Per Page | Wide Slots Per Page | Small Slots Per Page |
14
+ | home | 0 | 0 | 4 |
15
+
@@ -0,0 +1,22 @@
1
+ Feature: Content Templates
2
+ In order to change how the content looks and acts on the website a website editor will be able to select from predetermined templates
3
+
4
+ Background:
5
+ Given I am signed in as a website editor
6
+
7
+ Scenario: Create Root Content
8
+ Given I create a new root
9
+ Then I should be able select a template from the following:
10
+ | Template |
11
+ | Landing Page |
12
+
13
+ Scenario Outline: Create Child Content
14
+ Given I create a new child under a <Parent Template Name>
15
+ Then I should be able select a template from "<Allowed Templates>"
16
+
17
+ Examples:
18
+ | Parent Template Name | Allowed Templates |
19
+ | Home | Content Page |
20
+ #| Content Page | Content Page, Event Page |
21
+ #| Event Page | Content Page |
22
+
@@ -0,0 +1,84 @@
1
+ module DehumanizeClassName
2
+ # Convert a human readable class name into a class "my class" => MyClass
3
+ def dehumanize(human_name)
4
+ human_name.parameterize('_').pluralize.classify.constantize
5
+ end
6
+ end
7
+
8
+ World(DehumanizeClassName)
9
+
10
+ Given /^I am editing content$/ do
11
+ @_content = Factory(:content_page, :parent => Factory(:landing_page, :publish => true))
12
+ visit noodall_admin_node_path(@_content)
13
+ end
14
+
15
+ When /^I am editing the (.*)$/ do |model|
16
+ @_content = dehumanize(model).last
17
+ visit noodall_admin_node_path(@_content)
18
+ end
19
+
20
+ Then /^I should be able to place components in (\d+) (.*) slots$/ do |number, slot_type|
21
+ page.should have_css("#slot-list .#{slot_type}-slot", :count => number.to_i)
22
+ end
23
+
24
+ When /^I create a new root$/ do
25
+ visit new_noodall_admin_node_path
26
+ end
27
+
28
+ When /^I create a new child under a (.*)$/ do |template_title|
29
+ template = template_title.downcase.gsub(' ','_')
30
+ #create the ancester
31
+ parent = Factory(template.to_sym)
32
+
33
+ visit noodall_admin_node_nodes_path(parent)
34
+ click_link 'New'
35
+ end
36
+
37
+
38
+ Then /^I should be able select a template from the following:$/ do |table|
39
+ table.hashes.each do |row|
40
+ Then %{I should be able select a template from "#{row['Template']}"}
41
+ end
42
+ end
43
+
44
+ Then /^I should be able select a template from "([^\"]*)"$/ do |templates|
45
+ templates.split(',').map(&:strip).each do |template|
46
+ choose(template)
47
+ end
48
+ end
49
+
50
+ When /^(?:I|a website visitor) visit(?:s|) the (content|event|sport|landing|sports landing) page$/ do |type|
51
+ visit node_path(@_content)
52
+ end
53
+
54
+ Given /^an? ((?:[A-Z][a-z\-]*[ _]*)+)exists$/ do |template_title|
55
+ class_name = template_title.strip.gsub(' ','_').classify
56
+ @_content = Factory(class_name.tableize.singularize.to_sym, :publish => true)
57
+ end
58
+
59
+ Given /^the "([^\"]*)" ((?:[A-Z][a-z\-]*[ _]*)+)exists$/ do |node_title, template_title|
60
+ class_name = template_title.strip.gsub(' ','_').classify
61
+ @_content = Factory(class_name.tableize.singularize.to_sym, :title => node_title, :body => node_title, :publish => true)
62
+ end
63
+
64
+ Given /^the ((?:[A-Z][a-z\-]*[ _]*)+)has (\d+) ((?:[A-Z][a-z\-]*[ _]*)+)?children$/ do |parent_class_name, count, child_class_name|
65
+ parent_class_name = parent_class_name.strip.gsub(' ','_').classify
66
+ child_class_name = child_class_name.to_s.strip.gsub(' ','_').classify
67
+ child_class_name = Noodall::Node.first.class.name if child_class_name.blank?
68
+
69
+ assert @_content.is_a?(parent_class_name.constantize)
70
+ child_factory_name = child_class_name.tableize.singularize
71
+
72
+ @_content_children ||= []
73
+ count.to_i.times do
74
+ @_content_children << Factory(child_factory_name.to_sym, :publish => true, :parent => @_content)
75
+ end
76
+ end
77
+
78
+ Given /^each child has (\d+) children$/ do |count|
79
+ @_content_children.each do |child|
80
+ count.to_i.times do
81
+ Factory(:content_page, :parent => child, :publish => true)
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,46 @@
1
+ When /^(?:|I )click a "([^"]*)" component slot$/ do |slot_name|
2
+ @_slot_type = slot_name.downcase
3
+ within('ol#slot-list') do
4
+ click_link "#{slot_name} Slot"
5
+ end
6
+ end
7
+
8
+ When /^(?:|I )select the "([^\"]+)" component$/ do |component_name|
9
+ within "#fancybox-inner" do
10
+ select component_name, :from => 'Select the type of component'
11
+ end
12
+ end
13
+
14
+ When /^(?:|I )fill in the following within the component:$/ do |fields|
15
+ within "#fancybox-inner" do
16
+ fields.rows_hash.each do |name, value|
17
+ When %{I fill in "#{name}" with "#{value}"}
18
+ end
19
+ end
20
+ end
21
+
22
+ Then /^I add some images from the asset library$/ do
23
+ 5.times do |i|
24
+ Factory(:asset, :title => "Image #{i}")
25
+ end
26
+ page.find(:css, 'span.add-multi-asset').click
27
+ 3.times do |i|
28
+ within "#browser-list li:nth(#{i + 1})" do
29
+ click_link "Add"
30
+ end
31
+ end
32
+ page.find(:css, 'li.action a').click
33
+ end
34
+
35
+ When /^(?:|I )press "([^"]*)" within the component$/ do |button|
36
+ within "#fancybox-inner" do
37
+ click_button(button)
38
+ end
39
+ end
40
+
41
+ When /^(?:|I )select an image from the asset library$/ do
42
+ asset = Factory(:asset, :title => "My Image")
43
+ page.find(:css, 'span.select-file').click
44
+ click_link "Add"
45
+ sleep 5
46
+ end
@@ -0,0 +1,48 @@
1
+ Given /^I am signed in(?: as an? (.*))?$/ do |role|
2
+ role ||= 'user'
3
+ role = role.strip.gsub(/\W/,'_')
4
+
5
+ user = Factory(role)
6
+ Given %{I sign in as "#{user.email}/#{user.password}"}
7
+ end
8
+
9
+ Then /^I should see a list of users$/ do
10
+ page.should have_css('tbody tr', :count => 20)
11
+ end
12
+
13
+ # Database
14
+
15
+ Given /^a user exists with the attrubutes:$/ do |fields|
16
+ user = Factory :user, fields.rows_hash
17
+ end
18
+
19
+ Given /^I sign in as a (.+)$/ do |role|
20
+ user = create_model(role).first
21
+ user.confirm_email!
22
+ Given %{I sign in as "#{user.email}\/#{user.password}"}
23
+ end
24
+
25
+ # Actions
26
+
27
+ When /^I sign in as "(.*)\/(.*)"$/ do |email, password|
28
+ When %{I go to the sign in page}
29
+ And %{I fill in "user_email" with "#{email}"}
30
+ And %{I fill in "user_password" with "#{password}"}
31
+ And %{I press "Sign in"}
32
+ end
33
+
34
+ When /^I sign out$/ do
35
+ visit destroy_user_session_path
36
+ end
37
+
38
+ Then /^the user should (not )?be able to sign in as "(.*)\/(.*)"$/ do |yes_no, email, password|
39
+ Given %{I sign out}
40
+ And %{I sign in as "#{email}/#{password}"}
41
+ if yes_no.blank?
42
+ Then %{I should see "Signed in successfully"}
43
+ else
44
+ Then %{I should see "Invalid email or password."}
45
+ end
46
+ end
47
+
48
+