wagn 1.13.0.pre → 1.13.0.pre1

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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/app/controllers/card_controller.rb +4 -2
  4. data/db/bootstrap/card_references.yml +443 -408
  5. data/db/bootstrap/card_revisions.yml +1025 -1116
  6. data/db/bootstrap/cards.yml +2168 -2151
  7. data/db/migrate_cards/20140512155840_add_script_cards.rb +1 -0
  8. data/features/step_definitions/wagn_steps.rb +16 -3
  9. data/features/watch.feature +1 -1
  10. data/lib/card/content.rb +1 -1
  11. data/lib/card/format.rb +6 -4
  12. data/lib/card/generators/card_migration/USAGE +1 -1
  13. data/lib/card/mailer.rb +2 -1
  14. data/lib/card/mailer/confirmation_email.html.erb +6 -2
  15. data/lib/wagn/all.rb +0 -8
  16. data/lib/wagn/application.rb +29 -19
  17. data/lib/wagn/commands.rb +104 -2
  18. data/{config → lib/wagn/config}/environments/cucumber.rb +0 -0
  19. data/{config → lib/wagn/config}/environments/development.rb +0 -0
  20. data/{config → lib/wagn/config}/environments/production.rb +0 -0
  21. data/{config → lib/wagn/config}/environments/profile.rb +0 -0
  22. data/{config → lib/wagn/config}/environments/test.rb +0 -0
  23. data/{config → lib/wagn/config}/initializers/01_init_ruby_extensions.rb +0 -0
  24. data/{config → lib/wagn/config}/initializers/airbrake.rb +0 -1
  25. data/{config → lib/wagn/config}/initializers/inflections.rb +0 -0
  26. data/{config → lib/wagn/config}/initializers/mime_types.rb +0 -0
  27. data/{config → lib/wagn/config}/initializers/notification.rb +0 -0
  28. data/{config → lib/wagn/config}/initializers/recaptcha.rb +0 -0
  29. data/{config → lib/wagn/config}/initializers/secret_token.rb +0 -0
  30. data/{config → lib/wagn/config}/initializers/session_store.rb +0 -0
  31. data/{config → lib/wagn/config}/initializers/uuid_state_file.rb +0 -0
  32. data/lib/wagn/generators/wagn/USAGE +5 -4
  33. data/lib/wagn/generators/wagn/templates/Gemfile +67 -2
  34. data/lib/wagn/generators/wagn/templates/config/application.rb +1 -1
  35. data/lib/wagn/generators/wagn/templates/config/cucumber.yml +1 -0
  36. data/lib/wagn/generators/wagn/templates/config/databases/frontbase.yml +4 -2
  37. data/lib/wagn/generators/wagn/templates/config/databases/ibm_db.yml +4 -2
  38. data/lib/wagn/generators/wagn/templates/config/databases/jdbc.yml +5 -3
  39. data/lib/wagn/generators/wagn/templates/config/databases/jdbcmysql.yml +4 -2
  40. data/lib/wagn/generators/wagn/templates/config/databases/jdbcpostgresql.yml +4 -2
  41. data/lib/wagn/generators/wagn/templates/config/databases/jdbcsqlite3.yml +4 -2
  42. data/lib/wagn/generators/wagn/templates/config/databases/mysql.yml +5 -10
  43. data/lib/wagn/generators/wagn/templates/config/databases/oracle.yml +4 -2
  44. data/lib/wagn/generators/wagn/templates/config/databases/postgresql.yml +4 -15
  45. data/lib/wagn/generators/wagn/templates/config/databases/sqlite3.yml +4 -6
  46. data/lib/wagn/generators/wagn/templates/rspec +5 -0
  47. data/lib/wagn/generators/wagn/wagn_generator.rb +84 -1
  48. data/lib/wagn/mods_spec_helper.rb +66 -0
  49. data/lib/wagn/tasks/db.rake +2 -1
  50. data/lib/wagn/tasks/wagn.rake +5 -1
  51. data/lib/wagn/wagn_spec_helper.rb +49 -0
  52. data/mods/core/sets/all/content.rb +3 -3
  53. data/mods/core/sets/all/phases.rb +1 -2
  54. data/mods/standard/sets/all/attach.rb +1 -1
  55. data/mods/standard/sets/all/comment.rb +3 -3
  56. data/mods/standard/sets/all/rich_html.rb +6 -7
  57. data/mods/standard/sets/right/account.rb +14 -5
  58. data/mods/standard/sets/rstar/rules.rb +17 -4
  59. data/mods/standard/sets/self/signin.rb +2 -2
  60. data/mods/standard/sets/type/pointer.rb +1 -3
  61. data/mods/standard/sets/type/scss.rb +1 -1
  62. data/mods/standard/sets/type/signup.rb +33 -12
  63. data/mods/standard/sets/type/user.rb +1 -1
  64. data/spec/javascripts/support/jasmine_runner.rb +1 -1
  65. data/spec/mods/standard/sets/all/base_spec.rb +4 -0
  66. data/spec/mods/standard/sets/type/signup_spec.rb +52 -15
  67. data/spec/spec_helper.rb +12 -53
  68. data/test/fixtures/card_references.yml +688 -653
  69. data/test/fixtures/card_revisions.yml +1741 -1832
  70. data/test/fixtures/cards.yml +3484 -3467
  71. metadata +20 -21
  72. data/Gemfile +0 -77
  73. data/config/application.rb +0 -15
  74. data/config/boot.rb +0 -8
  75. data/config/environment.rb +0 -8
  76. data/lib/wagn/generators/wagn/templates/config/database.yml +0 -35
@@ -29,6 +29,7 @@ unless Rake::TaskManager.methods.include?(:redefine_task)
29
29
  end
30
30
  end
31
31
 
32
+
32
33
  namespace :db do
33
34
  namespace :fixtures do
34
35
  desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y"
@@ -36,7 +37,7 @@ namespace :db do
36
37
  require 'active_record/fixtures'
37
38
  ActiveRecord::Base.establish_connection(::Rails.env.to_sym)
38
39
  (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(Wagn.gem_root.to_s, 'test', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
39
- ActiveRecord::Fixtures.create_fixtures('test/fixtures', File.basename(fixture_file, '.*'))
40
+ ActiveRecord::Fixtures.create_fixtures(File.join(Wagn.gem_root.to_s, 'test', 'fixtures'), File.basename(fixture_file, '.*'))
40
41
  end
41
42
  end
42
43
  end
@@ -38,6 +38,10 @@ namespace :wagn do
38
38
  desc "update wagn gems and database"
39
39
  task :update do
40
40
  #system 'bundle update'
41
+ if Wagn.paths["tmp"].existent
42
+ FileUtils.rm_rf Wagn.paths["tmp"].first, :secure=>true
43
+ Dir.mkdir Wagn.paths["tmp"].first
44
+ end
41
45
  Rake::Task['wagn:migrate'].invoke
42
46
  # FIXME remove tmp dir / clear cache
43
47
  puts "set symlink for assets"
@@ -51,7 +55,7 @@ namespace :wagn do
51
55
 
52
56
  desc "set symlink for assets"
53
57
  task :update_assets_symlink do
54
- unless Rails.root.to_s == Wagn.gem_root
58
+ if Rails.root.to_s != Wagn.gem_root and not File.exists? File.join(Rails.public_path, "assets")
55
59
  FileUtils.ln_s( Wagn.paths['gem-assets'].first, File.join(Rails.public_path, "assets") )
56
60
  end
57
61
  end
@@ -0,0 +1,49 @@
1
+ module Wagn::WagnSpecHelper
2
+
3
+ include ActionDispatch::Assertions::SelectorAssertions
4
+ #~~~~~~~~~ HELPER METHODS ~~~~~~~~~~~~~~~#
5
+
6
+ def login_as user
7
+ Card::Auth.current_id = (uc=Card[user.to_s] and uc.id)
8
+ if @request
9
+ @request.session[:user] = Card::Auth.current_id
10
+ end
11
+ #warn "(ath)login_as #{user.inspect}, #{Card::Auth.current_id}, #{@request.session[:user]}"
12
+ end
13
+
14
+ def newcard name, content=""
15
+ #FIXME - misleading name; sounds like it doesn't save.
16
+ Card.create! :name=>name, :content=>content
17
+ end
18
+
19
+ def assert_view_select(view_html, *args, &block)
20
+ node = HTML::Document.new(view_html).root
21
+ if block_given?
22
+ assert_select node, *args, &block
23
+ else
24
+ assert_select node, *args
25
+ end
26
+ end
27
+
28
+ def render_editor(type)
29
+ card = Card.create(:name=>"my favority #{type} + #{rand(4)}", :type=>type)
30
+ card.format.render(:edit)
31
+ end
32
+
33
+ def render_content content, format_args={}
34
+ @card ||= Card.new :name=>"Tempo Rary 2"
35
+ @card.content = content
36
+ @card.format(format_args)._render :core
37
+ end
38
+
39
+ def render_card view, card_args={}, format_args={}
40
+ card = begin
41
+ if card_args[:name]
42
+ Card.fetch card_args[:name], :new=>card_args
43
+ else
44
+ Card.new card_args.merge( :name=> 'Tempo Rary' )
45
+ end
46
+ end
47
+ card.format(format_args)._render(view)
48
+ end
49
+ end
@@ -1,10 +1,10 @@
1
1
  ::Card.error_codes[:conflict] = [:conflict, 409]
2
2
 
3
3
  def content
4
- if new_card?
5
- template ? template.content : ''
6
- else
4
+ if !new_card?
7
5
  current_revision.content
6
+ elsif template && template.content.present?
7
+ template.content
8
8
  end
9
9
  end
10
10
 
@@ -106,11 +106,10 @@ end
106
106
  event :process_subcards, :after=>:approve, :on=>:save do
107
107
 
108
108
  subcards.keys.each do |sub_name|
109
- opts = @subcards[sub_name]
109
+ opts = @subcards[sub_name] || {}
110
110
  ab_name = sub_name.to_name.to_absolute_name name
111
111
  next if ab_name.key == key # don't resave self!
112
112
 
113
-
114
113
  opts = opts.stringify_keys
115
114
  opts['subcards'] = extract_subcard_args! opts
116
115
 
@@ -75,7 +75,7 @@ def attachment_link(rev_id) # create filesystem links to previous revision
75
75
  end
76
76
 
77
77
  def before_post_attach
78
- Rails.logger.info "bpa called for #{name}"
78
+ # Rails.logger.info "bpa called for #{name}"
79
79
  at=self.attach
80
80
  at.instance_write :file_name, at.original_filename
81
81
 
@@ -18,17 +18,17 @@ view( :comment_box, :denial=>:blank, :tags=>:unknown_ok, :perms=>lambda { |r| r.
18
18
 
19
19
 
20
20
  %{<div class="comment-box nodblclick"> #{
21
- card_form :update do |f|
21
+ card_form :update do
22
22
  %{
23
23
  #{ hidden_field_tag( 'card[name]', card.name ) if card.new_card?
24
24
  # FIXME wish we had more generalized solution for names. without this, nonexistent cards will often take left's linkname. (needs test)
25
25
  }
26
- #{ f.text_area :comment, :rows=>3 }
26
+ #{ form.text_area :comment, :rows=>3 }
27
27
  <div class="comment-buttons">
28
28
  #{
29
29
  unless Auth.signed_in?
30
30
  card.comment_author= (session[:comment_author] || params[:comment_author] || "Anonymous") #ENGLISH
31
- %{<label>My Name is:</label> #{ f.text_field :comment_author }}
31
+ %{<label>My Name is:</label> #{ form.text_field :comment_author }}
32
32
  end
33
33
  }
34
34
  <input type="submit" value="Comment"/>
@@ -195,7 +195,7 @@ format :html do
195
195
  end
196
196
 
197
197
  args[:buttons] ||= %{
198
- #{ submit_tag 'Submit', :class=>'create-submit-button', :disable_with=>'Submitting' }
198
+ #{ button_tag 'Submit', :class=>'create-submit-button', :disable_with=>'Submitting' }
199
199
  #{ button_tag 'Cancel', :type=>'button', :class=>"create-cancel-button #{cancel[:class]}", :href=>cancel[:href] }
200
200
  }
201
201
 
@@ -215,7 +215,7 @@ format :html do
215
215
  args[:optional_help] = :show
216
216
 
217
217
  args[:buttons] = %{
218
- #{ submit_tag 'Submit', :class=>'submit-button' }
218
+ #{ button_tag 'Submit', :class=>'submit-button' }
219
219
  #{ button_tag 'Cancel', :class=>'cancel-button slotter', :href=>path, :type=>'button' }
220
220
  }
221
221
  end
@@ -256,8 +256,8 @@ format :html do
256
256
  :card => { :update_referencers => false }
257
257
  )
258
258
  args[:buttons] = %{
259
- #{ submit_tag 'Rename and Update', :class=>'renamer-updater' }
260
- #{ submit_tag 'Rename', :class=>'renamer' }
259
+ #{ button_tag 'Rename and Update', :class=>'renamer-updater' }
260
+ #{ button_tag 'Rename', :class=>'renamer' }
261
261
  #{ button_tag 'Cancel', :class=>'slotter', :type=>'button', :href=>path(:view=>:edit, :id=>card.id)}
262
262
  }
263
263
 
@@ -278,7 +278,7 @@ format :html do
278
278
  args[:variety] = :edit #YUCK!
279
279
  args[:hidden] ||= { :view=>:edit }
280
280
  args[:buttons] = %{
281
- #{ submit_tag 'Submit', :disable_with=>'Submitting' }
281
+ #{ button_tag 'Submit', :disable_with=>'Submitting' }
282
282
  #{ button_tag 'Cancel', :href=>path(:view=>:edit), :type=>'button', :class=>'slotter' }
283
283
  }
284
284
  end
@@ -406,8 +406,7 @@ format :html do
406
406
  text = if args[:help_text]
407
407
  args[:help_text]
408
408
  else
409
- setting = card.new_card? ? :add_help : :help
410
- setting = [ :add_help, { :fallback => :help } ] if setting == :add_help
409
+ setting = card.new_card? ? [ :add_help, { :fallback => :help } ] : :help
411
410
 
412
411
  if help_card = card.rule_card( *setting ) and help_card.ok? :read
413
412
  with_inclusion_mode :normal do
@@ -52,7 +52,11 @@ event :set_default_status, :on=>:create, :before=>:process_subcards do
52
52
  subcards["+#{Card[:status].name}"] = { :content => default_status }
53
53
  end
54
54
 
55
- event :generate_confirmation_token, :on=>:create, :before=>:process_subcards do
55
+ def confirm_ok?
56
+ Card.new( :type_id=>Card.default_accounted_type_id ).ok? :create
57
+ end
58
+
59
+ event :generate_confirmation_token, :on=>:create, :before=>:process_subcards, :when=>proc{ |c| c.confirm_ok? } do
56
60
  subcards["+#{Card[:token].name}"] = {:content => generate_token }
57
61
  end
58
62
 
@@ -82,16 +86,21 @@ def has_reset_token?
82
86
  @env_token = Env.params[:reset_token]
83
87
  end
84
88
 
85
- event :send_new_account_confirmation_email, :on=>:create, :after=>:extend do
89
+ event :reset_token do
90
+ Auth.as_bot do
91
+ token_card.update_attributes! :content => generate_token
92
+ end
93
+ end
94
+
95
+
96
+ event :send_account_confirmation_email, :on=>:create, :after=>:extend do
86
97
  if self.email.present?
87
98
  Mailer.confirmation_email( self ).deliver
88
99
  end
89
100
  end
90
101
 
91
102
  event :send_reset_password_token do
92
- Auth.as_bot do
93
- token_card.update_attributes! :content => generate_token
94
- end
103
+ reset_token
95
104
  Mailer.password_reset(self).deliver
96
105
  end
97
106
 
@@ -1,3 +1,4 @@
1
+
1
2
  format :html do
2
3
 
3
4
  view :closed_rule, :tags=>:unknown_ok do |args|
@@ -39,6 +40,7 @@ format :html do
39
40
  setting_name = card.cardname.tag
40
41
  current_rule ||= Card.new :name=> "*all+#{setting_name}" #FIXME use codename
41
42
  set_selected = false
43
+ edit_mode = !params[:success] && card.ok?( ( card.new_card? ? :create : :update ) )
42
44
 
43
45
  #~~~~~~ handle reloading due to type change
44
46
  if params[:type_reload] && card_args=params[:card]
@@ -49,11 +51,10 @@ format :html do
49
51
  current_rule.assign_attributes card_args
50
52
  current_rule.include_set_modules
51
53
  end
52
-
53
54
  set_selected = card_args[:name].to_name.left_name.to_s
55
+ edit_mode = true
54
56
  end
55
57
 
56
- edit_mode = !params[:success] && card.ok?( ( card.new_card? ? :create : :update ) )
57
58
 
58
59
  opts = {
59
60
  :open_rule => card,
@@ -188,14 +189,26 @@ format :html do
188
189
  %{<span class="rule-delete-section">#{ button_tag 'Delete', b_args }</span>}
189
190
  end
190
191
  }
191
- #{ submit_tag 'Submit', :class=>'rule-submit-button' }
192
+ #{ button_tag 'Submit', :class=>'rule-submit-button' }
192
193
  #{ button_tag 'Cancel', :class=>'rule-cancel-button slotter', :type=>'button',
193
- :href=>path( :view=>( card.new_card? ? :closed_rule : :open_rule ), :card=>open_rule, :item=>:view_rule ) }
194
+ :href=>path( :view=>( card.new_card? ? :closed_rule : :open_rule ), :success=>true ) }
194
195
  </div>
195
196
  }
196
197
  end
197
198
  end
198
199
 
200
+ =begin
201
+ view :edit_rule2 do |args|
202
+ card_form :update do
203
+ [
204
+ _optional_render( :type_fieldset, args ),
205
+ _optional_render( :content_fieldset, args ),
206
+ _optional_render( :set_fieldset, args ),
207
+ _optional_render( :button_fieldset, args )
208
+ ]
209
+ end
210
+ end
211
+ =end
199
212
 
200
213
  private
201
214
 
@@ -13,7 +13,7 @@ format :html do
13
13
 
14
14
 
15
15
  view :core do |args|
16
- args[:buttons] = submit_tag 'Sign in'
16
+ args[:buttons] = button_tag 'Sign in'
17
17
  if Card.new(:type_id=>Card::SignupID).ok? :create
18
18
  args[:buttons] += link_to( '...or sign up!', wagn_path("account/signup"))
19
19
  end
@@ -43,7 +43,7 @@ format :html do
43
43
  args.merge!( {
44
44
  :title=>'Forgot Password',
45
45
  :optional_help=>:hide,
46
- :buttons => submit_tag( 'Reset my password' ),
46
+ :buttons => button_tag( 'Reset my password' ),
47
47
  :structure => true,
48
48
  :hidden => {
49
49
  :reset_password => true,
@@ -147,8 +147,6 @@ end
147
147
 
148
148
 
149
149
  event :standardize_items, :before=>:approve, :on=>:save do
150
- Rails.logger.info "create.rb standardize_items base"
151
-
152
150
  if updates.for? :content
153
151
  self.content = item_names(:context=>:raw).map { |name| "[[#{name}]]" }.join "\n"
154
152
  end
@@ -172,7 +170,7 @@ end
172
170
 
173
171
  def item_names args={}
174
172
  context = args[:context] || self.cardname
175
- self.raw_content.split(/\n+/).map do |line|
173
+ self.raw_content.to_s.split(/\n+/).map do |line|
176
174
  item_name = line.gsub /\[\[|\]\]/, ''
177
175
  if context == :raw
178
176
  item_name
@@ -14,7 +14,7 @@ def compressed_css input
14
14
  end
15
15
  end
16
16
 
17
- machine_input do
17
+ machine_input do
18
18
  compressed_css format(:format => :css)._render_core
19
19
  end
20
20
 
@@ -5,7 +5,7 @@ format :html do
5
5
  #FIXME - make more use of standard new view
6
6
  args.merge!(
7
7
  :optional_help => :show, #, :optional_menu=>:never
8
- :buttons => submit_tag( 'Submit' ),
8
+ :buttons => button_tag( 'Submit' ),
9
9
  :hidden => {
10
10
  :success => (card.rule(:thanks) || '_self'),
11
11
  'card[type_id]' => card.type_id
@@ -26,11 +26,30 @@ format :html do
26
26
 
27
27
 
28
28
  view :core do |args|
29
- #ENGLISH
30
- process_content(_render_raw) +
31
- if (card.new_card?); '' else
32
- %{<div class="invite-links"><strong>#{card.name}</strong> requested an account on #{format_date(card.created_at) }</div>}
29
+ headings, links = [], []
30
+ if !card.new_card? #necessary?
31
+ headings << %(<strong>#{ card.name }</strong> requested an account on #{ format_date card.created_at })
32
+ if account = card.account
33
+ if account.token
34
+ headings << "An activation token has been sent for this account"
35
+ else
36
+ if account.confirm_ok?
37
+ links << link_to( "Approve #{card.name}", wagn_path("/update/~#{card.id}?approve=true") )
38
+ end
39
+ if card.ok? :delete
40
+ links << link_to( "Deny #{card.name}", wagn_path("/delete/~#{card.id}") )
41
+ end
42
+ headings << links * '' if links.any?
43
+ end
44
+ else
45
+ headings << "ERROR: signup card missing account"
46
+ end
33
47
  end
48
+ %{<div class="invite-links">
49
+ #{ headings.map { |h| "<div>#{h}</div>"} * "\n" }
50
+ </div>
51
+ #{ process_content render_raw }
52
+ }
34
53
  end
35
54
  end
36
55
 
@@ -56,12 +75,16 @@ def has_token?
56
75
  end
57
76
 
58
77
 
78
+ event :approve_account, :on=>:update, :before=>:process_subcards, :when=>proc {|c| Env.params[:approve] } do
79
+ account.reset_token
80
+ account.send_account_confirmation_email
81
+ end
82
+
83
+
59
84
  event :resend_activation_token do
60
- Auth.as_bot do
61
- token_card = Auth.find_token_card @env_token
62
- token_card.update_attributes! :content => generate_token
63
- token_card.left.send_new_account_confirmation_email
64
- end
85
+ account = Auth.find_token_card( @env_token ).left
86
+ account.reset_token
87
+ account.send_account_confirmation_email
65
88
  Env.params[:success] = {
66
89
  :id => '_self',
67
90
  :view => 'message',
@@ -88,5 +111,3 @@ event :signup_notifications, :after=>:extend, :on=>:create, :when=>send_signup_n
88
111
  Mailer.signup_alert(self).deliver
89
112
  end
90
113
 
91
-
92
-
@@ -30,7 +30,7 @@ format :html do
30
30
  :optional_help=>:show,
31
31
  :optional_menu=>:never,
32
32
  :help_text=>'To get started, set up an account.',
33
- :buttons => submit_tag( 'Submit' ),
33
+ :buttons => button_tag( 'Submit' ),
34
34
  :hidden => {
35
35
  :success => "REDIRECT: #{ Card.path_setting '/' }",
36
36
  'card[type_id]' => Card.default_accounted_type_id,
@@ -1,4 +1,4 @@
1
- # -*- encoding : utf-8 -*-
1
+ #-*- encoding : utf-8 -*-
2
2
  $:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes
3
3
 
4
4
  require 'rubygems'
@@ -22,6 +22,10 @@ describe Card::Set::All::Base do
22
22
  it "core" do
23
23
  render_card(:core, :name=>'A+B').should == "AlphaBeta"
24
24
  end
25
+
26
+ it 'core for new card' do
27
+ Card.new.format._render_core.should == ''
28
+ end
25
29
 
26
30
  describe 'array' do
27
31
  it "of search items" do
@@ -8,7 +8,7 @@ describe Card::Set::Type::Signup do
8
8
  end
9
9
 
10
10
 
11
- context 'request form' do
11
+ context 'signup form form' do
12
12
  before do
13
13
  card = Card.new :type_id=>Card::SignupID
14
14
  @form = card.format.render_new
@@ -29,17 +29,17 @@ describe Card::Set::Type::Signup do
29
29
 
30
30
  Card::Auth.as_bot do
31
31
  Card.create! :name=>'User+*type+*create', :content=>'[[Anyone]]'
32
- Card.create! :name=>'*request+*to', :content=>'request@wagn.org'
32
+ Card.create! :name=>'*request+*to', :content=>'signups@wagn.org'
33
33
  end
34
- @request = Card.create! :name=>'Big Bad Wolf', :type_id=>Card::SignupID, '+*account'=>{
34
+ @signup = Card.create! :name=>'Big Bad Wolf', :type_id=>Card::SignupID, '+*account'=>{
35
35
  '+*email'=>'wolf@wagn.org', '+*password'=>'wolf'
36
36
  }
37
- @account = @request.account
37
+ @account = @signup.account
38
38
  @token = @account.token
39
39
  end
40
40
 
41
41
  it 'should create all the necessary cards' do
42
- @request.type_id.should == Card::SignupID
42
+ @signup.type_id.should == Card::SignupID
43
43
  @account.email.should == 'wolf@wagn.org'
44
44
  @account.status.should == 'pending'
45
45
  @account.salt.should_not == ''
@@ -51,19 +51,19 @@ describe Card::Set::Type::Signup do
51
51
  end
52
52
 
53
53
  it 'should create an authenticable token' do
54
- Card::Auth.authenticate_by_token(@token).should == @request.id
54
+ Card::Auth.authenticate_by_token(@token).should == @signup.id
55
55
  end
56
56
 
57
57
  it 'should notify someone' do
58
- ActionMailer::Base.deliveries.last.to.should == ['request@wagn.org']
58
+ ActionMailer::Base.deliveries.last.to.should == ['signups@wagn.org']
59
59
  end
60
60
 
61
61
  it 'should be activated by an update' do
62
62
  Card::Env.params[:token] = @token
63
- @request.update_attributes({})
64
- #puts @request.errors.full_messages * "\n"
65
- @request.errors.should be_empty
66
- @request.type_id.should == Card::UserID
63
+ @signup.update_attributes({})
64
+ #puts @signup.errors.full_messages * "\n"
65
+ @signup.errors.should be_empty
66
+ @signup.type_id.should == Card::UserID
67
67
  @account.status.should == 'active'
68
68
  Card[ @account.name ].active?.should be_true
69
69
  end
@@ -73,7 +73,7 @@ describe Card::Set::Type::Signup do
73
73
  @account.token_card.expire
74
74
  Card::Env.params[:token] = @token
75
75
 
76
- result = @request.update_attributes!({})
76
+ result = @signup.update_attributes!({})
77
77
  result.should == true # successfully completes save
78
78
  @account.token.should_not == @token # token gets updated
79
79
  success = Card::Env.params[:success]
@@ -84,10 +84,47 @@ describe Card::Set::Type::Signup do
84
84
 
85
85
 
86
86
  context 'signup (with approval)' do
87
+ before do
88
+ # NOTE: by default Anonymous does not have permission to create User cards.
89
+ Card::Auth.as_bot do
90
+ Card.create! :name=>'*request+*to', :content=>'signups@wagn.org'
91
+ end
92
+ @signup = Card.create! :name=>'Big Bad Wolf', :type_id=>Card::SignupID, '+*account'=>{
93
+ '+*email'=>'wolf@wagn.org', '+*password'=>'wolf'
94
+ }
95
+ @account = @signup.account
96
+ end
97
+
98
+
99
+ it 'should create all the necessary cards, but no token' do
100
+ @signup.type_id.should == Card::SignupID
101
+ @account.email.should == 'wolf@wagn.org'
102
+ @account.status.should == 'pending'
103
+ @account.salt.should_not == ''
104
+ @account.password.length.should > 10 #encrypted
105
+ end
106
+
107
+ it 'should not create a token' do
108
+ @account.token.should_not be_present
109
+ end
110
+
111
+ it 'should notify someone' do
112
+ ActionMailer::Base.deliveries.last.to.should == ['signups@wagn.org']
113
+ end
114
+
115
+ context 'approval' do
116
+ before do
117
+ Card::Env.params[:approve] = true
118
+ Card::Auth.as :joe_admin
119
+ end
120
+
121
+ it 'should create token' do
122
+ @signup = Card.fetch @signup.id
123
+ @signup.save!
124
+ @signup.account.token.should be_present
125
+ end
126
+ end
87
127
 
88
128
  end
89
-
90
-
91
-
92
129
 
93
130
  end