test/seed.rb in wagn-1.12.13 vs test/seed.rb in wagn-1.13.0.pre
- old
+ new
@@ -2,81 +2,67 @@
require 'timecop'
require_dependency 'card'
# following looks like legacy code to me - efm
-Dir["#{Rails.root}/app/models/card/*.rb"].sort.each do |cardtype|
- require_dependency cardtype
-end
+#Dir["#{Rails.root}/app/models/card/*.rb"].sort.each do |cardtype|
+# require_dependency cardtype
+#end
class SharedData
- def self.add_test_data
- #Account.current_id = Card::WagnBotID
- CodenameTable.load_bootcodes unless !Card::Codename[:wagn_bot].nil?
+ def self.account_args hash
+ { "+*account" => { "+*password" =>'joe_pass' }.merge( hash ) }
+ end
+ def self.add_test_data
+
Wagn::Cache.reset_global
- Wagn::Env.reset
- Wagn::Env[:no_auto_approval] = true
- Account.as(Card::WagnBotID)
+ Card::Env.reset
+ Card::Auth.as_bot
+ Card.create! :name=>"Joe User", :type_code=>'user', :content=>"I'm number two", :subcards=>account_args( '+*email'=>'joe@user.com' )
+ Card.create! :name=>"Joe Admin", :type_code=>'user', :content=>"I'm number one", :subcards=>account_args( '+*email'=>'joe@admin.com' )
+ Card.create! :name=>"Joe Camel", :type_code=>'user', :content=>"Mr. Buttz", :subcards=>account_args( '+*email'=>'joe@camel.com' )
- account_args = { :status=>'active', :password=>'joe_pass', :password_confirmation=>'joe_pass' }
+ Card['Joe Admin'].fetch(:trait=>:roles, :new=>{}).items = [ Card::AdministratorID ]
- Card.create! :name=>"Joe User", :type_code=>'user', :content=>"I'm number two", :account_args=>account_args.merge( :login=>"joe_user", :email=>'joe@user.com' )
- Card.create! :name=>"Joe Admin", :type_code=>'user', :content=>"I'm number one", :account_args=>account_args.merge( :login=>"joe_admin", :email=>'joe@admin.com' )
- Card.create! :name=>"Joe Camel", :type_code=>'user', :content=>"Mr. Buttz", :account_args=>account_args.merge( :login=>"joe_camel", :email=>'joe@camel.com' )
-
- Card['Joe Admin'].fetch(:trait=>:roles, :new=>{}).items = [ Card::AdminID ]
-
# generic, shared attribute card
color = Card.create! :name=>"color"
basic = Card.create! :name=>"Basic Card"
# data for testing users and account requests
- Card.create! :name=>"Ron Request", :type_id=>Card::AccountRequestID, :account_args=>{
- :email=>'ron@request.com', :password=>'ron_pass', :password_confirmation=>'ron_pass', :status=>'pending'
- }
-
Card.create! :type_code=>'user', :name=>"No Count", :content=>"I got no account"
- # CREATE A CARD OF EACH TYPE
- Card.create! :name=>"Sample User", :type_code=>'user', :account_args=>{
- :login=>"sample_user", :email=>'sample@user.com', :status=>'active', :password=>'sample_pass', :password_confirmation=>'sample_pass'
- }
+ Card.create! :name=>"Sample User", :type_code=>'user', :subcards=>account_args('+*email'=>'sample@user.com', '+*password'=>'sample_pass')
- request_card = Card.create! :type_code=>'account_request', :name=>"Sample AccountRequest" #, :email=>"invitation@request.com"
+ # CREATE A CARD OF EACH TYPE
- Account.createable_types.each do |type|
- next if ['User', 'Account Request', 'Set', 'Number'].include? type
+ Card.create! :type_id=>Card::SignupID, :name=>"Sample Signup" #, :email=>"invitation@request.com"
+ #above still necessary? try commenting out above and 'Sign up' below
+
+ Card::Auth.createable_types.each do |type|
+ next if ['User', 'Sign up', 'Set', 'Number'].include? type
Card.create! :type=>type, :name=>"Sample #{type}"
end
# data for role_test.rb
- Card.create! :name=>"u1", :type_code=>'user', :account_args=>{
- :login=>"u1", :email=>'u1@user.com', :status=>'active', :password=>'u1_pass', :password_confirmation=>'u1_pass'
- }
+ Card.create! :name=>"u1", :type_code=>'user', :subcards=>account_args('+*email'=>'u1@user.com', '+*password'=>'u1_pass')
+ Card.create! :name=>"u2", :type_code=>'user', :subcards=>account_args('+*email'=>'u2@user.com', '+*password'=>'u2_pass')
+ Card.create! :name=>"u3", :type_code=>'user', :subcards=>account_args('+*email'=>'u3@user.com', '+*password'=>'u3_pass')
- Card.create! :name=>"u2", :type_code=>'user', :account_args=>{
- :login=>"u2", :email=>'u2@user.com', :status=>'active', :password=>'u2_pass', :password_confirmation=>'u2_pass'
- }
-
- Card.create! :name=>"u3", :type_code=>'user', :account_args=>{
- :login=>"u3", :email=>'u3@user.com', :status=>'active', :password=>'u3_pass', :password_confirmation=>'u3_pass'
- }
-
r1 = Card.create!( :type_code=>'role', :name=>'r1' )
r2 = Card.create!( :type_code=>'role', :name=>'r2' )
r3 = Card.create!( :type_code=>'role', :name=>'r3' )
r4 = Card.create!( :type_code=>'role', :name=>'r4' )
Card['u1'].fetch( :trait=>:roles, :new=>{} ).items = [ r1, r2, r3 ]
Card['u2'].fetch( :trait=>:roles, :new=>{} ).items = [ r1, r2, r4 ]
- Card['u3'].fetch( :trait=>:roles, :new=>{} ).items = [ r1, r4, Card::AdminID ]
+ Card['u3'].fetch( :trait=>:roles, :new=>{} ).items = [ r1, r4, Card::AdministratorID ]
c1 = Card.create! :name=>'c1'
c2 = Card.create! :name=>'c2'
c3 = Card.create! :name=>'c3'
@@ -108,25 +94,25 @@
Card.create! :type_code=>'cardtype_c', :name=>"type-c-card", :content=>"type_c_content"
Card.create! :type_code=>'cardtype_d', :name=>"type-d-card", :content=>"type_d_content"
Card.create! :type_code=>'cardtype_e', :name=>"type-e-card", :content=>"type_e_content"
Card.create! :type_code=>'cardtype_f', :name=>"type-f-card", :content=>"type_f_content"
- #warn "current user #{User.session_user.inspect}. always ok? #{Account.always_ok?}"
+ #warn "current user #{User.session_user.inspect}. always ok? #{Card::Auth.always_ok?}"
c = Card.create! :name=>'revtest', :content=>'first'
c.update_attributes! :content=>'second'
c.update_attributes! :content=>'third'
#Card.create! :type_code=>'cardtype', :name=>'*priority'
# for template stuff
Card.create! :type_id=>Card::CardtypeID, :name=> "UserForm"
Card.create! :name=>"UserForm+*type+*structure", :content=>"{{+name}} {{+age}} {{+description}}"
- Account.current_id = Card['joe_user'].id
+ Card::Auth.current_id = Card['joe_user'].id
Card.create!( :name=>"JoeLater", :content=>"test")
Card.create!( :name=>"JoeNow", :content=>"test")
- Account.current_id = Card::WagnBotID
+ Card::Auth.current_id = Card::WagnBotID
Card.create!(:name=>"AdminNow", :content=>"test")
Card.create :name=>'Cardtype B+*type+*create', :type=>'Pointer', :content=>'[[r1]]'
Card.create! :type=>"Cardtype", :name=>"Book"
@@ -137,18 +123,13 @@
### -------- Notification data ------------
Timecop.freeze(Wagn.future_stamp - 1.day) do
# fwiw Timecop is apparently limited by ruby Time object, which goes only to 2037 and back to 1900 or so.
# whereas DateTime can represent all dates.
- Card.create! :name=>"John", :type_code=>'user', :account_args=>{
- :login=>"john", :email=>'john@user.com', :status=>'active', :password=>'john_pass', :password_confirmation=>'john_pass'
- }
+ Card.create! :name=>"John", :type_code=>'user', :subcards=>account_args('+*email'=>'john@user.com', '+*password'=>'john_pass')
+ Card.create! :name=>"Sara", :type_code=>'user', :subcards=>account_args('+*email'=>'sara@user.com', '+*password'=>'sara_pass')
- Card.create! :name=>"Sara", :type_code=>'user', :account_args=>{
- :login=>"sara",:email=>'sara@user.com', :status => 'active', :password=>'sara_pass', :password_confirmation=>'sara_pass'
- }
-
Card.create! :name => "Sara Watching+*watchers", :content => "[[Sara]]"
Card.create! :name => "All Eyes On Me+*watchers", :content => "[[Sara]]\n[[John]]"
Card.create! :name => "John Watching", :content => "{{+her}}"
Card.create! :name => "John Watching+*watchers", :content => "[[John]]"
Card.create! :name => "John Watching+her"
@@ -156,37 +137,29 @@
Card.create! :name => "Optic", :type => "Cardtype"
Card.create! :name => "Optic+*watchers", :content => "[[Sara]]"
Card.create! :name => "Sunglasses", :type=>"Optic", :content=>"{{+tint}}"
Card.create! :name => "Sunglasses+tint"
-
- # TODO: I would like to setup these card definitions with something like Cucumbers table feature.
end
## --------- create templated permissions -------------
ctt = Card.create! :name=> 'Cardtype E+*type+*default'
## --------- Fruit: creatable by anon but not readable ---
f = Card.create! :type=>"Cardtype", :name=>"Fruit"
- Card.create :name=>'Fruit+*type+*create', :type=>'Pointer', :content=>'[[Anyone]]'
- Card.create :name=>'Fruit+*type+*read', :type=>'Pointer', :content=>'[[Administrator]]'
+ Card.create! :name=>'Fruit+*type+*create', :type=>'Pointer', :content=>'[[Anyone]]'
+ Card.create! :name=>'Fruit+*type+*read', :type=>'Pointer', :content=>'[[Administrator]]'
- # codenames for card_attribute tests
-Rails.logger.warn "add codenames status and write"
- Card.create! :name=>'*status', :codename=>:status
+ # codenames for card_accessor tests
Card.create! :name=>'*write', :codename=>:write
-Rails.logger.warn "added codenames status and write"
# -------- For toc testing: ------------
- Card.create :name=>"OnneHeading", :content => "<h1>This is one heading</h1>\r\n<p>and some text</p>"
- Card.create :name=>'TwwoHeading', :content => "<h1>One Heading</h1>\r\n<p>and some text</p>\r\n<h2>And a Subheading</h2>\r\n<p>and more text</p>"
- Card.create :name=>'ThreeHeading', :content =>"<h1>A Heading</h1>\r\n<p>and text</p>\r\n<h2>And Subhead</h2>\r\n<p>text</p>\r\n<h1>And another top Heading</h1>"
+ Card.create! :name=>"OnneHeading", :content => "<h1>This is one heading</h1>\r\n<p>and some text</p>"
+ Card.create! :name=>'TwwoHeading', :content => "<h1>One Heading</h1>\r\n<p>and some text</p>\r\n<h2>And a Subheading</h2>\r\n<p>and more text</p>"
+ Card.create! :name=>'ThreeHeading', :content =>"<h1>A Heading</h1>\r\n<p>and text</p>\r\n<h2>And Subhead</h2>\r\n<p>text</p>\r\n<h1>And another top Heading</h1>"
- c=Card.fetch 'Basic+*type+*table_of_contents', :new=>{}
- c.content='2'
- c.save
end
end