ankh 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. data/.gitignore +18 -0
  2. data/{spec/spec.opts → .rspec} +0 -0
  3. data/.rvmrc +1 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +4 -2
  6. data/README.rdoc +15 -5
  7. data/Rakefile +6 -84
  8. data/ankh.gemspec +20 -67
  9. data/lib/..rb +5 -0
  10. data/lib/ankh.rb +4 -6
  11. data/lib/ankh/model.rb +18 -10
  12. data/lib/ankh/question.rb +1 -1
  13. data/lib/ankh/railtie.rb +8 -0
  14. data/lib/ankh/validations/{human.rb → human_validator.rb} +0 -12
  15. data/lib/ankh/version.rb +3 -0
  16. data/spec/ankh/model_spec.rb +10 -7
  17. data/spec/dummy/Rakefile +7 -0
  18. data/spec/dummy/api_docs/api_authentication.markdown +70 -0
  19. data/spec/dummy/api_docs/api_user_creates_user.markdown +1170 -0
  20. data/spec/dummy/api_docs/partner_creation.markdown +78 -0
  21. data/spec/dummy/api_docs/topic_creation.markdown +76 -0
  22. data/spec/dummy/api_docs/user_creation.markdown +31 -0
  23. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  24. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  25. data/spec/dummy/app/controllers/application_controller.rb +4 -0
  26. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  27. data/{features/step_definitions/ankh_steps.rb → spec/dummy/app/mailers/.gitkeep} +0 -0
  28. data/spec/dummy/app/models/.gitkeep +0 -0
  29. data/spec/dummy/app/views/devise/confirmations/new.html.erb +15 -0
  30. data/spec/dummy/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  31. data/spec/dummy/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  32. data/spec/dummy/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  33. data/spec/dummy/app/views/devise/passwords/edit.html.erb +19 -0
  34. data/spec/dummy/app/views/devise/passwords/new.html.erb +15 -0
  35. data/spec/dummy/app/views/devise/registrations/edit.html.erb +22 -0
  36. data/spec/dummy/app/views/devise/registrations/new.html.erb +20 -0
  37. data/spec/dummy/app/views/devise/sessions/new.html.erb +15 -0
  38. data/spec/dummy/app/views/devise/sessions/new.mobile.erb +14 -0
  39. data/spec/dummy/app/views/devise/shared/_links.erb +25 -0
  40. data/spec/dummy/app/views/devise/unlocks/new.html.erb +15 -0
  41. data/spec/dummy/config.ru +4 -0
  42. data/spec/dummy/config/application.rb +45 -0
  43. data/spec/dummy/config/boot.rb +10 -0
  44. data/spec/dummy/config/database.yml +20 -0
  45. data/spec/dummy/config/environment.rb +5 -0
  46. data/spec/dummy/config/environments/development.rb +30 -0
  47. data/spec/dummy/config/environments/production.rb +60 -0
  48. data/spec/dummy/config/environments/test.rb +39 -0
  49. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  50. data/spec/dummy/config/initializers/inflections.rb +10 -0
  51. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  52. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  53. data/spec/dummy/config/initializers/session_store.rb +8 -0
  54. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  55. data/spec/dummy/config/locales/en.yml +5 -0
  56. data/spec/dummy/config/routes.rb +3 -0
  57. data/spec/dummy/db/development.sqlite3 +0 -0
  58. data/spec/dummy/db/schema.rb +188 -0
  59. data/spec/dummy/db/test.sqlite3 +0 -0
  60. data/spec/dummy/lib/assets/.gitkeep +0 -0
  61. data/spec/dummy/public/404.html +26 -0
  62. data/spec/dummy/public/422.html +26 -0
  63. data/spec/dummy/public/500.html +26 -0
  64. data/spec/dummy/public/favicon.ico +0 -0
  65. data/spec/dummy/script/rails +6 -0
  66. data/spec/spec_helper.rb +10 -14
  67. metadata +205 -130
  68. data/features/ankh.feature +0 -9
  69. data/features/support/env.rb +0 -4
  70. data/lib/ankh/rails/legacy.rb +0 -41
  71. data/spec/support/active_record_spec_helper.rb +0 -44
@@ -0,0 +1,78 @@
1
+ ---
2
+ layout: page
3
+ title: Partner Creation
4
+ comments: false
5
+ sharing: false
6
+ footer: true
7
+ ---
8
+
9
+ ## allows partner creation if valid api token ##
10
+
11
+ Sample Request URI:
12
+
13
+ ```
14
+ POST /api/partners.json?api_token=FASDFGXA10
15
+ Body: partner[name]=new_partner&partner[subdomain]=new_subdomain
16
+ ```
17
+
18
+ Sample Response:
19
+
20
+ Status: 201
21
+
22
+ ```javascript
23
+ {
24
+ "created_at": "2011-12-12T22:34:30Z",
25
+ "id": 550,
26
+ "idea_rating_system_id": null,
27
+ "intro_text": null,
28
+ "name": "new_partner",
29
+ "plan_tier": "freemium",
30
+ "rating_system_id": 999,
31
+ "subdomain": "new_subdomain",
32
+ "updated_at": "2011-12-12T22:34:30Z"
33
+ }
34
+ ```
35
+
36
+ ## denies partner creation if no partner name or subdomain is provided ##
37
+
38
+ Sample Request URI:
39
+
40
+ ```
41
+ POST /api/partners.json?api_token=FASDFGXA11
42
+ Body:
43
+ ```
44
+
45
+ Sample Response:
46
+
47
+ Status: 422
48
+
49
+ ```javascript
50
+ {
51
+ "name": [
52
+ "can't be blank"
53
+ ],
54
+ "subdomain": [
55
+ "can't be blank"
56
+ ]
57
+ }
58
+ ```
59
+
60
+ ## denies partner creation if no api token is provided ##
61
+
62
+ Sample Request URI:
63
+
64
+ ```
65
+ POST /unauthenticated
66
+ Body: partner[name]=new_partner&partner[subdomain]=new_subdomain
67
+ ```
68
+
69
+ Sample Response:
70
+
71
+ Status: 401
72
+
73
+ ```javascript
74
+ {
75
+ "error": "You need to sign in or sign up before continuing."
76
+ }
77
+ ```
78
+
@@ -0,0 +1,76 @@
1
+ ---
2
+ layout: page
3
+ title: Topic Creation
4
+ comments: false
5
+ sharing: false
6
+ footer: true
7
+ ---
8
+
9
+ ## authenticated user can create a topic ##
10
+
11
+ Sample Request URI:
12
+
13
+ ```
14
+ POST /api/topics.json?api_token=FASDFGXA12
15
+ Body: topic[title]=topic+title&topic[description]=topic+description&topic[external_id]=1234
16
+ ```
17
+
18
+ Sample Response:
19
+
20
+ Status: 201
21
+
22
+ ```javascript
23
+ {
24
+ "average_rating_score": null,
25
+ "closed_at": null,
26
+ "created_at": "2011-12-12T22:34:30Z",
27
+ "description": "topic description",
28
+ "external_id": "1234",
29
+ "id": 296,
30
+ "partner_id": 551,
31
+ "ratings_count": 0,
32
+ "title": "topic title",
33
+ "updated_at": "2011-12-12T22:34:30Z"
34
+ }
35
+ ```
36
+
37
+ ## authenticated user can not create a topic without a title or description ##
38
+
39
+ Sample Request URI:
40
+
41
+ ```
42
+ POST /api/topics.json?api_token=FASDFGXA13
43
+ Body: topic[title]=here+is+a+title&topic[description]=
44
+ ```
45
+
46
+ Sample Response:
47
+
48
+ Status: 422
49
+
50
+ ```javascript
51
+ {
52
+ "description": [
53
+ "can't be blank"
54
+ ]
55
+ }
56
+ ```
57
+
58
+ ## unauthenticated user can not create a topic ##
59
+
60
+ Sample Request URI:
61
+
62
+ ```
63
+ POST /unauthenticated
64
+ Body: topic[title]=topic+title&topic[description]=topic+description
65
+ ```
66
+
67
+ Sample Response:
68
+
69
+ Status: 401
70
+
71
+ ```javascript
72
+ {
73
+ "error": "You need to sign in or sign up before continuing."
74
+ }
75
+ ```
76
+
@@ -0,0 +1,31 @@
1
+ ---
2
+ layout: page
3
+ title: User Creation
4
+ comments: false
5
+ sharing: false
6
+ footer: true
7
+ ---
8
+
9
+ ## create a valid user ##
10
+
11
+ Sample Request URI:
12
+
13
+ ```
14
+ POST /api/users.json?api_token=FASDFGXA14
15
+ Body: user[external_id]=external_id
16
+ ```
17
+
18
+ Sample Response:
19
+
20
+ Status: 201
21
+
22
+ ```javascript
23
+ {
24
+ "email": "kaya_keebler@example.com",
25
+ "external_id": "external_id",
26
+ "first_name": null,
27
+ "last_name": null,
28
+ "login": "kaya_keebler"
29
+ }
30
+ ```
31
+
@@ -0,0 +1,9 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require jquery
8
+ //= require jquery_ujs
9
+ //= require_tree .
@@ -0,0 +1,7 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *= require_self
6
+ *= require_tree .
7
+ */
@@ -0,0 +1,4 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
4
+
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
@@ -0,0 +1,15 @@
1
+ <h2>Resend confirmation instructions</h2>
2
+
3
+ <%= simple_form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
4
+ <%= f.error_notification %>
5
+
6
+ <div class="inputs">
7
+ <%= f.input :email, :required => true %>
8
+ </div>
9
+
10
+ <div class="actions">
11
+ <%= f.button :submit, "Resend confirmation instructions" %>
12
+ </div>
13
+ <% end %>
14
+
15
+ <%= render :partial => "devise/shared/links" %>
@@ -0,0 +1,5 @@
1
+ <p>Welcome <%= @resource.email %>!</p>
2
+
3
+ <p>You can confirm your account through the link below:</p>
4
+
5
+ <p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
@@ -0,0 +1,8 @@
1
+ <p>Hello <%= @resource.email %>!</p>
2
+
3
+ <p>Someone has requested a link to change your password, and you can do this through the link below.</p>
4
+
5
+ <p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
6
+
7
+ <p>If you didn't request this, please ignore this email.</p>
8
+ <p>Your password won't change until you access the link above and create a new one.</p>
@@ -0,0 +1,7 @@
1
+ <p>Hello <%= @resource.email %>!</p>
2
+
3
+ <p>Your account has been locked due to an excessive amount of unsuccessful sign in attempts.</p>
4
+
5
+ <p>Click the link below to unlock your account:</p>
6
+
7
+ <p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
@@ -0,0 +1,19 @@
1
+ <h2>Change your password</h2>
2
+
3
+ <%= simple_form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
4
+ <%= f.error_notification %>
5
+
6
+ <%= f.input :reset_password_token, :as => :hidden %>
7
+ <%= f.full_error :reset_password_token %>
8
+
9
+ <div class="inputs">
10
+ <%= f.input :password, :label => "New Password", :required => true %>
11
+ <%= f.input :password_confirmation, :label => "New Password Confirmation", :required => true %>
12
+ </div>
13
+
14
+ <div class="actions">
15
+ <%= f.button :submit, "Change my Password" %>
16
+ </div>
17
+ <% end %>
18
+
19
+ <%= render :partial => "devise/shared/links" %>
@@ -0,0 +1,15 @@
1
+ <h2>Forgot your password?</h2>
2
+
3
+ <%= simple_form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
4
+ <%= f.error_notification %>
5
+
6
+ <div class="inputs">
7
+ <%= f.input :email, :required => true %>
8
+ </div>
9
+
10
+ <div class="actions">
11
+ <%= f.button :submit, "Send Reset Instructions" %>
12
+ </div>
13
+ <% end %>
14
+
15
+ <%= render :partial => "devise/shared/links" %>
@@ -0,0 +1,22 @@
1
+ <h2>Edit <%= resource_name.to_s.humanize %></h2>
2
+
3
+ <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
4
+ <%= f.error_notification %>
5
+
6
+ <div class="inputs">
7
+ <%= f.input :email, :autofocus => true %>
8
+ <%= f.input :password, :hint => "leave it blank if you don't want to change it", :required => false %>
9
+ <%= f.input :password_confirmation, :required => false %>
10
+ <%= f.input :current_password, :hint => "we need your current password to confirm your changes", :required => true %>
11
+ </div>
12
+
13
+ <div class="actions">
14
+ <%= f.button :submit, "Update" %>
15
+ </div>
16
+ <% end %>
17
+
18
+ <h3>Cancel my account</h3>
19
+
20
+ <p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.</p>
21
+
22
+ <%= link_to "Back", :back %>
@@ -0,0 +1,20 @@
1
+ <h2>Sign up</h2>
2
+
3
+ <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
4
+ <%= f.error_notification %>
5
+
6
+ <div class="inputs">
7
+ <%= f.input :email, :autofocus => true %>
8
+ <%= f.input :login %>
9
+ <%= f.input :first_name %>
10
+ <%= f.input :last_name %>
11
+ <%= f.input :password %>
12
+ <%= f.input :password_confirmation %>
13
+ </div>
14
+
15
+ <div class="actions">
16
+ <%= f.button :submit %>
17
+ </div>
18
+ <% end %>
19
+
20
+ <%= render :partial => "devise/shared/links" %>
@@ -0,0 +1,15 @@
1
+ <h2>Sign in</h2>
2
+
3
+ <%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), html: { class: "sign_in" }) do |f| %>
4
+ <div class="inputs">
5
+ <%= f.input :email, :required => false, :autofocus => true %>
6
+ <%= f.input :password, :required => false %>
7
+ <%= f.input :remember_me, :as => :boolean if devise_mapping.rememberable? %>
8
+ </div>
9
+
10
+ <div class="actions">
11
+ <%= f.button :submit, "Sign In", class: "btn primary"%>
12
+ </div>
13
+ <% end %>
14
+
15
+ <%= render :partial => "devise/shared/links" %>
@@ -0,0 +1,14 @@
1
+ <h2>Sign in</h2>
2
+
3
+ <%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), html: { class: "sign_in" }) do |f| %>
4
+ <div class="inputs">
5
+ <%= f.input :email, :required => false, :autofocus => true %>
6
+ <%= f.input :password, :required => false %>
7
+ <%= f.input :remember_me, :as => :boolean if devise_mapping.rememberable? %>
8
+ </div>
9
+
10
+ <div class="actions">
11
+ <%= f.button :submit, "Sign In" %>
12
+ </div>
13
+ <% end %>
14
+
@@ -0,0 +1,25 @@
1
+ <%- if controller_name != 'sessions' %>
2
+ <%= link_to "Sign in", new_session_path(resource_name) %><br />
3
+ <% end -%>
4
+
5
+ <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
6
+ <%= link_to "Sign up", new_registration_path(resource_name) %><br />
7
+ <% end -%>
8
+
9
+ <%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
10
+ <%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
11
+ <% end -%>
12
+
13
+ <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
14
+ <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
15
+ <% end -%>
16
+
17
+ <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
18
+ <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
19
+ <% end -%>
20
+
21
+ <%- if devise_mapping.omniauthable? %>
22
+ <%- resource_class.omniauth_providers.each do |provider| %>
23
+ <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
24
+ <% end -%>
25
+ <% end -%>
@@ -0,0 +1,15 @@
1
+ <h2>Resend unlock instructions</h2>
2
+
3
+ <%= simple_form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
4
+ <%= f.error_notification %>
5
+
6
+ <div class="inputs">
7
+ <%= f.input :email, :required => true %>
8
+ </div>
9
+
10
+ <div class="actions">
11
+ <%= f.button :submit, "Resend unlock instructions" %>
12
+ </div>
13
+ <% end %>
14
+
15
+ <%= render :partial => "devise/shared/links" %>
@@ -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 Dummy::Application
@@ -0,0 +1,45 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require
6
+ require "ankh"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Custom directories with classes and modules you want to be autoloadable.
15
+ # config.autoload_paths += %W(#{config.root}/extras)
16
+
17
+ # Only load the plugins named here, in the order given (default is alphabetical).
18
+ # :all can be used as a placeholder for all plugins not explicitly named.
19
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
20
+
21
+ # Activate observers that should always be running.
22
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
23
+
24
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
25
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
26
+ # config.time_zone = 'Central Time (US & Canada)'
27
+
28
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
29
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
30
+ # config.i18n.default_locale = :de
31
+
32
+ # Configure the default encoding used in templates for Ruby 1.9.
33
+ config.encoding = "utf-8"
34
+
35
+ # Configure sensitive parameters which will be filtered from the log file.
36
+ config.filter_parameters += [:password]
37
+
38
+ # Enable the asset pipeline
39
+ config.assets.enabled = true
40
+
41
+ # Version of your assets, change this if you want to expire all your assets
42
+ config.assets.version = '1.0'
43
+ end
44
+ end
45
+