Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Action events #70

Merged
merged 127 commits into from

2 participants

@GerryG
Collaborator

This should be a pretty good intermediate point towards admin_cards. It isn't quite ready, but not very far away. Good place to start working on events API.

Gerry Gleason added some commits
Gerry Gleason a start d07e537
Gerry Gleason Merge branch 'reference_types' into action_events c6125e8
Gerry Gleason ... ed18734
Gerry Gleason ... f9217b5
Gerry Gleason mostly working b4ac46b
Gerry Gleason Pretty much all working, a few details, tests to move, coverage to ex…
…tend
44bbc93
Gerry Gleason Merge branch 'reference_types' into action_events fe39af9
Gerry Gleason Merge branch 'reference_types' into action_events 97f8820
Gerry Gleason Merge branch 'reference_types' into action_events fd1bf88
Gerry Gleason Merge branch 'reference_types' into action_events 42c1fbe
Gerry Gleason Pull forward the move of test/functioin/* to specs, (not all working) ad17ac9
Gerry Gleason Not completely working, but many tests moved from test/*, basic event…
… processing is working for CRUD actions
b7ef6cd
Gerry Gleason All cuc passing, all test/functional and test/integration moved to specs 40c1713
Gerry Gleason cherry-pick parts of action_events e21abf5
Gerry Gleason Merge ethan's pending branches forward (locations, menus_and_icons) 34b1870
Gerry Gleason Merge rebased parts forward 9e0b74e
Gerry Gleason make migrations work after merge 0a9eac4
Gerry Gleason ... f06e682
Gerry Gleason merge forward, just some notificatons broken now 0197f13
Gerry Gleason merge develop b6f0f39
Gerry Gleason Merge branch 'fix_tests' into action_develop 801e1a7
Gerry Gleason Merge branch 'reference_types' into action_reference 5632176
Gerry Gleason merge reference_types 538b72a
Gerry Gleason Merge branch 'action_develop' into action_reference 26317ef
Gerry Gleason Still working on merge, going back to merge forward 9aeb486
Gerry Gleason merge load_cardlib into action_reference 66ebbf0
Gerry Gleason Merging obj_render into action_(events)reference (forward code with b…
…asic events
a949f70
Gerry Gleason Merge obj_render again because I didn't have all the commits in my ob…
…j_render yet
1098be3
Gerry Gleason merge aciton_reference to action_events e987a58
Gerry Gleason Merge branch 'load_cardlib' into action_events 6626286
Gerry Gleason Almost all working, breakthrough in loading actions 1a5df99
Gerry Gleason Merge latest forward from load_cardlib through obj_render and clean u…
…p extra set nesting at the same time
249ed12
Gerry Gleason Merge obj_render c8928c6
Gerry Gleason Add admin cards migration (codenames for routing cards) 64df038
Gerry Gleason Revert the xml/json removal commit on json_xml branch 16c729a
Gerry Gleason Merge branch 'obj_render' into json_xml 22d53a5
Gerry Gleason Merge remote-tracking branch 'origin/obj_render' into json_xml 24f0289
Gerry Gleason merge forward (manually) the cleanup of the renderer calling code aa3e36e
Gerry Gleason Merge some cleanups forward (adding back parts) de767b8
Gerry Gleason Merge branch 'obj_render' into json_xml 9a15bac
Gerry Gleason revert removal (probably should just edit the commit to add it) cc08cfb
Gerry Gleason Merge branch 'obj_render' into json_xml 9a00cb8
Gerry Gleason Merge of obj_render into action_events (need json_xml too now) 6e77f75
Gerry Gleason wip, action_events needs a bit of work c95b2bc
Gerry Gleason Merge 1.10.3 forward 0c86ad2
Gerry Gleason Merge :session codename disable 8900c74
Gerry Gleason merge ab74e10
Gerry Gleason Merge branch 'obj_render' into action_events 2b4c277
Gerry Gleason Merge updates forward 16cb73c
Gerry Gleason Merge obj_render 0fce9ad
Gerry Gleason merge json_xml 0763616
Gerry Gleason Merge obj_content dcc7045
Gerry Gleason Merge branch 'json_xml' into action_events 14800e7
Gerry Gleason to_actions through obj_render to json_xml 3e4fe46
Gerry Gleason Merge branch 'obj_render' into json_xml 1e85b22
Gerry Gleason Merge obj_content for new commits (to_actions) cc9e816
Gerry Gleason Merge branch 'obj_render' into json_xml 13234a1
Gerry Gleason Merge develop into action_events (to_actions and one from ethan) cab2b8c
Gerry Gleason Merge to_actions forward via obj_render to json_xml c79d7fa
Gerry Gleason Merge forward to_actions 4053250
Gerry Gleason Double included removed d1b8792
Gerry Gleason Merge branch 'obj_render' into json_xml 1ae9625
Gerry Gleason Merge json_xml to action_events 2908d25
Gerry Gleason Merge remote-tracking branch 'origin/action_events' into action_events 05e3d68
Gerry Gleason Merge branch 'obj_render' into json_xml 7dbf109
Gerry Gleason merge 387af72
Gerry Gleason Merge branch 'obj_render' into json_xml 6933dcc
Gerry Gleason Merge branch 'json_xml' into action_events 9654f3a
Gerry Gleason removing parts that should be just in admin_cards now ba4c533
Gerry Gleason Remove json_xml parts
Conflicts:

	spec/lib/wagn/renderer/xml_spec.rb
258105c
app/controllers/application_controller.rb
@@ -96,9 +96,12 @@ def show view = nil, status = 200
case
when known # renderers can handle it
+ # FIXME: generalize this so it can be overriden when registering a renderer
+ obj_sym = [:json, :xml].member?( ext = ext.to_sym ) ? ext : :text
@GerryG Collaborator
GerryG added a note

I'm not how this interacts with the limited json we have. Need to be sure to test that and fix this (maybe just :text for now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
app/controllers/card_controller.rb
((15 lines not shown))
+ def action
+ @action = METHODS[request.method]
+ Rails.logger.warn "action #{request.method}, #{@action} #{params.inspect}"
+ warn "action #{request.method}, #{@action} #{params.inspect}"
+ send "perform_#{@action}"
+ render_errors || success
+ end
+
+ def action_method event
+ return "_final_#{event}" unless card && subset_actions[event]
+ card.method_keys.each do |method_key|
+ meth = "_final_"+(method_key.blank? ? "#{event}" : "#{method_key}_#{event}")
+ #warn "looking up #{method_key}, M:#{meth} for #{card.name}"
+ return meth if respond_to?(meth.to_sym)
+ end
+ end
@GerryG Collaborator
GerryG added a note

These may not actually be used on this branch. Need to double check the dependencies on json_xml and admin_cards. It shouldn't interfere when not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@ethn
Collaborator

Lots of great work here! I like what you've done with the perform calls.

I think we should get to work on mapping action relationships soon. I need to get some things clearer in my head (or better yet, out of it)

@GerryG
Collaborator

Cool, yes that will be important. I'm struggling a bit to gather the working bits of some of the more specific actions (self-actions for session/admin action and similar), but it is slowly coming together again.

The basics of the "action relationships" is more or less the base actions in this branch now. You've done some recent work on cleaning up some of the base action methods and error rendering, and I'm pretty sure that is all merged correctly here, but we'll have to be careful that we have it all.

@GerryG
Collaborator

Is this notifications working again?

It added an issue for this PR in my inbox.

Github UI is a bit of a mystery here.

app/controllers/card_controller.rb
((3 lines not shown))
require_dependency 'cardlib'
class CardController < ApplicationController
+ include Wagn::Sets::CardActions
@GerryG Collaborator
GerryG added a note

This is the module that action methods (perform_*) are defined, and they should be all loaded by now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
app/controllers/card_controller.rb
((11 lines not shown))
+
+ METHODS = {
+ 'POST' => :create, # C
+ 'GET' => :read, # R
+ 'PUT' => :update, # U
+ 'DELETE' => :delete, # D
+ 'INDEX' => :index
+ }
+
+ # this form of dispatching is not used yet, write specs first, then integrate into routing
+ def action
+ @action = METHODS[request.method]
+ Rails.logger.warn "action #{request.method}, #{@action} #{params.inspect}"
+ #warn "action #{request.method}, #{@action} #{params.inspect}"
+ send "perform_#{@action}"
+ render_errors || success
@GerryG Collaborator
GerryG added a note

Not sure it this is used right now. We would want it for full RESTful routes. I see no real downside in adding it now, even if we aren't using it yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
app/controllers/card_controller.rb
((35 lines not shown))
- if card.new_card?
- create
- elsif card.update_attributes params[:card]
- success
- else
- render_errors
- end
- end
-
- def delete
- if card.delete
- discard_locations_for card #should be an event
- success 'REDIRECT: *previous'
- else
- render_errors
+ def action_method event
@GerryG Collaborator
GerryG added a note

This is the helper that finds the method name for both definitions and performing actions. These will be the methods imported from CardActions above.

This has the full sets definitions, just like define view, but in this branch, I don't think we have defined any beyond the base group for the 'all' set. If I recall correctly, I added this first on admin_cards where I was turning the account and admin controllers into actions. Then I decided I had to pull the minimum up to develop, but we were stalled on the migrations then, so the original work in admin_cards is badly out of date, while this part is now all synchronized and working with the backlog all merged up and even released.

admin_cards may have had some other things mixed in, but we should be able to pick out some important bits from it and restart. I may have tried to resynchronize it and messed it up a bit. account_cards first, and that is pretty close now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
app/controllers/card_controller.rb
((56 lines not shown))
end
end
- #FIXME! move into renderer
- def read_file
- if card.ok? :read
- show_file
- else
- show :denial
- end
- end
+ def create; perform_create end
+ def read ; perform_read end
+ def update; perform_update end
+ def delete; perform_delete end
+ def index ; perform_read end
+ def read_file; perform_read_file end
@GerryG Collaborator
GerryG added a note

I don't see why we can't do this with alias, right? Upside is one less method call. Downside?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/chunks/chunk.rb
((19 lines not shown))
- pindex = pend
- ch_class.pattern
- end * '|'
- /(.*?)(#{chunk_pattern})/m
+ cattr_accessor :prefix_cfg
+ @@prefix_cfg = {}
+
+ def Abstract::scan_re(chunk_types)
+ /(?:#{
+ chunk_types.map do |chunk_cl|
+ cfg = chunk_cl.config
+ prefix = cfg[:idx_char] || :default
+ @@prefix_cfg[prefix] = cfg
+ cfg[:prefix_re]
+ end * '|'
+ })/mo
@GerryG Collaborator
GerryG added a note

This is css_fix stuff. Sorry, I pre-merged because css_fix is done from my perspective and I wanted it in already. Merge css_fix and this will go away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/old_modules/google_maps_addon.rb
@@ -24,12 +24,13 @@ def update_geocode
if conf = Card['*geocode']
if self.junction? && conf.item_names.include?( self.cardname.tag )
address = conf.item_names.map{ |p|
- c=Card.fetch( self.cardname.trunk_name.to_s+"+#{p}", :new=>{}) and
- c.content }.select(&:present?) * ', '
- if (geocode = GoogleMapsAddon.geocode(address))
- c = Card.fetch "#{self.cardname.trunk_name.to_s}+*geocode", :new=>{ :type_id=>Card::PhraseID }
- c.save if c.new_card?
- c.update_attributes( :content => geocode )
+ card=Card.fetch( self.cardname.trunk_name.to_s+"+#{p}", :new=>{} ) and
+ card.content }.select(&:present?) * ', '
+ if geocode = GoogleMapsAddon.geocode(address)
+ card = Card.fetch "#{self.cardname.trunk_name.to_s}+*geocode", :new=>{:type_id=>Card::PhraseID}
+ card.content = geocode
+ card.save if card.new_card?
+ card.update_attributes( :content => geocode )
@GerryG Collaborator
GerryG added a note

This is just a rename of c -> card (local var), want me to pull it into a cleanup branch to merge first?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/wagn/renderer.rb
@@ -13,10 +13,14 @@ class Renderer
RENDERERS = { #should be defined in renderer
:json => :JsonRenderer,
:email => :EmailHtml,
+ :html => :HtmlRenderer,
@GerryG Collaborator
GerryG added a note

Asked you about this in Skype too. I think we actually want to change it back (delete this line and rename the file), but otherwise maybe we want to split it out with other simple changes? Your call.

@ethn Collaborator
ethn added a note

my inclination is to solve the autoloading issue first. this started with jsonrenderer, and we had all kinds of problems when the file was just json.rb

@GerryG Collaborator
GerryG added a note

Well, I don't recall for sure, but I never wanted to use the JsonRenderer version, but you wanted to be conservative. I always thought any manifestation of this sort of conflict was a bug to be fixed, not adapted to. I believe it is fixed now and will attempt to change it that way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@GerryG GerryG closed this
@GerryG
Collaborator

I think this was accidentally closed when I mistakenly deleted a branch in the repo (then readded it)

@GerryG GerryG reopened this
lib/wagn/set/all/base.rb
((26 lines not shown))
+ action :delete do |*a|
+ if card.delete
+ discard_locations_for card #should be an event
+ success 'REDIRECT: *previous'
+ else
+ render_errors
+ end
+ end
+
+ action :read_file do |*a|
+ if card.ok? :read
+ show_file
+ else
+ wagn_redirect "#{params[:id]}?view=denial"
+ end
+ end
@ethn Collaborator
ethn added a note

we don't want a read_file action. read_file is going into a renderer and will be handled by read.

@GerryG Collaborator
GerryG added a note

Is that a future oriented comment of how it needs to be?

Would we need a renderer for each file extension? Or would it be above in the :read action in the base renderer, and handle them as general classes?

@GerryG Collaborator
GerryG added a note

Good news is, there is test coverage.

I need some feedback on above questions to proceed in a reasonable direction ... or feel free to send code ...

@ethn Collaborator
ethn added a note

#read_file is gone from develop branch (moved into a renderer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/wagn/set/right/template_right.rb
@@ -1,5 +1,6 @@
module Wagn
- module Set::Right::Template
+ module Set::Right::TemplateRight
@GerryG Collaborator
GerryG added a note

This seems unnecessary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
app/controllers/application_controller.rb
@@ -91,7 +91,7 @@ def show view = nil, status = 200
renderer = Wagn::Renderer.new card, :controller=>self, :format=>format
result = renderer.render_show opts
- status = renderer.error_status || status
+ status = card.error_status || status
@GerryG Collaborator
GerryG added a note

I'm thinking this is a merge error. Any hints from your side?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@ethn
Collaborator

oooh, I like "renerder" :)

Gerry Gleason added some commits
Gerry Gleason Remove read_file 2fcc4d5
Gerry Gleason ... 29be35c
@GerryG
Collaborator

Misspelled commit comments are my specialty :)

@ethn
Collaborator

I think we're going in a pretty different direction with the events API now. But it looks like there is a lot of work in this branch moving tests to specs. Would that be easy to pull out?

@GerryG GerryG commented on the diff
spec/controllers/sets_spec.rb
((6 lines not shown))
+ it "module exists and autoloads" do
+ Wagn::Sets.should be_true
+ end
+
+ describe "read all set" do
+ it "gets data" do
+ get :read, :id=>'a'
+ end
+ end
+
+ describe ".process_read" do
+ before do
+ end
+
+ it "invokes actions on matching cards" do
+ end
@GerryG Collaborator
GerryG added a note

Need to fill in a few cases here ...

@ethn Collaborator
ethn added a note

we don't actually have any functionality here yet, right?

I'm not totally clear on what we want in the realm of read-triggered actions yet. We should probably gather some use cases. Any in particular live for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
spec/models/card/trash_spec.rb
@@ -14,7 +14,7 @@
it "should come out of the trash when a plus card is created" do
Account.as_bot do
Card.create(:name=>'A+*acct')
- c = Card['A']
+ c = Card.fetch 'A', :new=>{}
@ethn Collaborator
ethn added a note

the new shouldn't be necessary, right? Point is that the A should be pulled out of the trash and created. The :new kind of kills the test, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@ethn ethn commented on the diff
lib/wagn/renderer.rb
@@ -466,7 +464,7 @@ class Renderer::Csv < Renderer::Text ; end
class Renderer::Css < Renderer::Text ; end
class Renderer::Data < Renderer ; end
- class Renderer::JsonRenderer < Renderer::Data ; end
+ class Renderer::Json < Renderer::Data ; end
@ethn Collaborator
ethn added a note

the issue here was when we had the json renderer in a separate file (which I think we really want). I'm now thinking we should do a lot less auto loading, which could solve this. In any case, this is fine for now, because at least it's more consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@ethn ethn merged commit 900e6b4 into wagn:develop
@GerryG GerryG deleted the GerryG:action_events branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 13, 2012
  1. a start

    Gerry Gleason authored
  2. Merge branch 'reference_types' into action_events

    Gerry Gleason authored
  3. ...

    Gerry Gleason authored
  4. ...

    Gerry Gleason authored
  5. mostly working

    Gerry Gleason authored
Commits on Dec 14, 2012
  1. Merge branch 'reference_types' into action_events

    Gerry Gleason authored
  2. Merge branch 'reference_types' into action_events

    Gerry Gleason authored
  3. Merge branch 'reference_types' into action_events

    Gerry Gleason authored
  4. Merge branch 'reference_types' into action_events

    Gerry Gleason authored
Commits on Dec 17, 2012
  1. Not completely working, but many tests moved from test/*, basic event…

    Gerry Gleason authored
    … processing is working for CRUD actions
Commits on Dec 18, 2012
Commits on Dec 19, 2012
  1. cherry-pick parts of action_events

    Gerry Gleason authored
  2. Merge rebased parts forward

    Gerry Gleason authored
  3. make migrations work after merge

    Gerry Gleason authored
  4. ...

    Gerry Gleason authored
Commits on Dec 24, 2012
  1. merge forward, just some notificatons broken now

    Gerry Gleason authored
  2. merge develop

    Gerry Gleason authored
  3. Merge branch 'fix_tests' into action_develop

    Gerry Gleason authored
  4. Merge branch 'reference_types' into action_reference

    Gerry Gleason authored
  5. merge reference_types

    Gerry Gleason authored
Commits on Dec 26, 2012
  1. Merge branch 'action_develop' into action_reference

    Gerry Gleason authored
Commits on Jan 10, 2013
  1. Still working on merge, going back to merge forward

    Gerry Gleason authored
  2. merge load_cardlib into action_reference

    Gerry Gleason authored
  3. Merging obj_render into action_(events)reference (forward code with b…

    Gerry Gleason authored
    …asic events
  4. Merge obj_render again because I didn't have all the commits in my ob…

    Gerry Gleason authored
    …j_render yet
  5. merge aciton_reference to action_events

    Gerry Gleason authored
  6. Merge branch 'load_cardlib' into action_events

    Gerry Gleason authored
Commits on Jan 11, 2013
  1. Almost all working, breakthrough in loading actions

    Gerry Gleason authored
  2. Merge latest forward from load_cardlib through obj_render and clean u…

    Gerry Gleason authored
    …p extra set nesting at the same time
Commits on Jan 12, 2013
  1. Merge obj_render

    Gerry Gleason authored
  2. Add admin cards migration (codenames for routing cards)

    Gerry Gleason authored
Commits on Jan 13, 2013
  1. Revert the xml/json removal commit on json_xml branch

    Gerry Gleason authored
  2. Merge branch 'obj_render' into json_xml

    Gerry Gleason authored
  3. Merge some cleanups forward (adding back parts)

    Gerry Gleason authored
  4. Merge branch 'obj_render' into json_xml

    Gerry Gleason authored
  5. Merge branch 'obj_render' into json_xml

    Gerry Gleason authored
Commits on Jan 14, 2013
Commits on Jan 15, 2013
  1. wip, action_events needs a bit of work

    Gerry Gleason authored
  2. Merge 1.10.3 forward

    Gerry Gleason authored
  3. Merge :session codename disable

    Gerry Gleason authored
  4. merge

    Gerry Gleason authored
  5. Merge branch 'obj_render' into action_events

    Gerry Gleason authored
Commits on Jan 17, 2013
  1. Merge updates forward

    Gerry Gleason authored
  2. Merge obj_render

    Gerry Gleason authored
  3. merge json_xml

    Gerry Gleason authored
  4. Merge obj_content

    Gerry Gleason authored
  5. Merge branch 'json_xml' into action_events

    Gerry Gleason authored
  6. to_actions through obj_render to json_xml

    Gerry Gleason authored
  7. Merge branch 'obj_render' into json_xml

    Gerry Gleason authored
  8. Merge obj_content for new commits (to_actions)

    Gerry Gleason authored
Commits on Jan 18, 2013
  1. Merge branch 'obj_render' into json_xml

    Gerry Gleason authored
  2. Merge to_actions forward via obj_render to json_xml

    Gerry Gleason authored
  3. Merge forward to_actions

    Gerry Gleason authored
  4. Double included removed

    Gerry Gleason authored
Commits on Jan 19, 2013
  1. Merge branch 'obj_render' into json_xml

    Gerry Gleason authored
  2. Merge json_xml to action_events

    Gerry Gleason authored
  3. Merge branch 'obj_render' into json_xml

    Gerry Gleason authored
  4. merge

    Gerry Gleason authored
Commits on Jan 20, 2013
  1. Merge branch 'obj_render' into json_xml

    Gerry Gleason authored
  2. Merge branch 'json_xml' into action_events

    Gerry Gleason authored
Commits on Jan 23, 2013
  1. removing parts that should be just in admin_cards now

    Gerry Gleason authored
  2. Remove json_xml parts

    Gerry Gleason authored
    Conflicts:
    
    	spec/lib/wagn/renderer/xml_spec.rb
  3. Some card_controller cleanup

    Gerry Gleason authored
  4. Maybe ATP?

    Gerry Gleason authored
Commits on Jan 26, 2013
  1. Merge develop into action_events

    Gerry Gleason authored
  2. ...

    Gerry Gleason authored
  3. Merge branch 'develop' into action_events

    Gerry Gleason authored
  4. Merge fixups

    Gerry Gleason authored
Commits on Jan 31, 2013
  1. Merge branch 'develop' into action_events

    Gerry Gleason authored
  2. ...

    Gerry Gleason authored
Commits on Feb 1, 2013
  1. Merge branch 'simple_stuff' into action_events

    Gerry Gleason authored
  2. Merge branch 'simple_stuff' into action_events

    Gerry Gleason authored
  3. fix tests

    Gerry Gleason authored
  4. Merge branch 'simple_stuff' into action_events

    Gerry Gleason authored
  5. Merge branch 'develop' into action_events

    Gerry Gleason authored
Commits on Feb 2, 2013
  1. merge simple_stuff to action_events

    Gerry Gleason authored
Commits on Feb 3, 2013
  1. Merge branch 'develop' into action_events

    Gerry Gleason authored
Commits on Feb 7, 2013
  1. Merge branch 'css_fix' into action_events

    Gerry Gleason authored
  2. fix account_spec with authorized -> current update

    Gerry Gleason authored
  3. Merge branch 'css_fix' into action_events

    Gerry Gleason authored
Commits on Feb 9, 2013
  1. Merge develop

    Gerry Gleason authored
  2. Fix merge

    Gerry Gleason authored
  3. Merge branch 'develop' into action_events

    Gerry Gleason authored
  4. Merge branch 'develop' into action_events

    Gerry Gleason authored
Commits on Feb 10, 2013
  1. Put aliases for base actions into sets definitions

    Gerry Gleason authored
  2. Remove cardtype.rb, not needed anymore

    Gerry Gleason authored
Commits on Feb 17, 2013
  1. Removing Renderer suffix from clasnames

    Gerry Gleason authored
  2. Merge branch 'renderer_name' into action_events

    Gerry Gleason authored
Commits on Feb 19, 2013
Commits on Mar 1, 2013
  1. Merge latest develop to action_events

    Gerry Gleason authored
Commits on Mar 2, 2013
  1. merge latest develop to action_events

    Gerry Gleason authored
Commits on Mar 5, 2013
  1. Merge branch 'develop' into action_events

    Gerry Gleason authored
  2. Fix after merge

    Gerry Gleason authored
Commits on Mar 6, 2013
  1. Merge branch 'develop' into action_events

    Gerry Gleason authored
Commits on Mar 9, 2013
  1. merge

    Gerry Gleason authored
Commits on Mar 11, 2013
  1. Merge branch 'develop' into action_events

    Gerry Gleason authored
Commits on Mar 15, 2013
  1. Merge tagged release

    Gerry Gleason authored
Commits on Mar 24, 2013
  1. Merge branch 'develop' into action_events

    Gerry Gleason authored
Commits on Mar 25, 2013
  1. Merge branch 'develop' into action_events

    Gerry Gleason authored
Commits on Mar 27, 2013
  1. Merge branch 'develop' into action_events

    Gerry Gleason authored
Commits on Apr 27, 2013
  1. merge

    Gerry Gleason authored
Commits on May 1, 2013
  1. Merge branch 'develop' into action_events

    Gerry Gleason authored
Commits on May 2, 2013
  1. added attr_* from develop (missed in merge)

    Gerry Gleason authored
  2. Missed some code in first merge

    Gerry Gleason authored
Commits on May 3, 2013
  1. Remove read_file

    Gerry Gleason authored
Commits on May 4, 2013
  1. ...

    Gerry Gleason authored
Commits on May 10, 2013
  1. Merge branch 'develop' into action_events

    Gerry Gleason authored
Commits on May 15, 2013
  1. Merge branch 'develop' into action_events

    Gerry Gleason authored
Commits on May 22, 2013
  1. Merge branch 'develop' into action_events

    Gerry Gleason authored
Commits on Jun 6, 2013
  1. Merge out old action stuff

    Gerry Gleason authored
  2. Remove a few changes we probably don't want

    Gerry Gleason authored
  3. Take pending away on 2 (they work)

    Gerry Gleason authored
  4. Merge branch 'develop' into action_events

    Gerry Gleason authored
Commits on Jun 7, 2013
  1. Remove wrong test change

    Gerry Gleason authored
This page is out of date. Refresh to see the latest.
View
1  app/models/card/reference.rb
@@ -66,4 +66,5 @@ def repair_all
end
end
+
end
View
2  app/models/user.rb
@@ -40,7 +40,7 @@ def create_ok?
# FIXME: args=params. should be less coupled..
def create_with_card user_args, card_args, email_args={}
card_args[:type_id] ||= Card::UserID
- @card = Card.fetch(card_args[:name], :new=>card_args)
+ @card = Card.fetch card_args[:name], :new => card_args
Account.as_bot do
@account = User.new(user_args)
@account.status = 'active' unless user_args.has_key? :status
View
18 lib/wagn/renderer.rb
@@ -1,6 +1,5 @@
# -*- encoding : utf-8 -*-
-
module Wagn
class Renderer
@@ -9,13 +8,16 @@ class Renderer
cattr_accessor :current_slot, :ajax_call, :perms, :denial_views, :subset_views, :error_codes, :view_tags, :current_class
@@current_class = Renderer
+ attr_reader :format, :card, :root, :parent
+ attr_accessor :form, :main_content, :error_status
+
+
DEPRECATED_VIEWS = { :view=>:open, :card=>:open, :line=>:closed, :bare=>:core, :naked=>:core }
INCLUSION_MODES = { :main=>:main, :closed=>:closed, :closed_content=>:closed, :edit=>:edit,
:layout=>:layout, :new=>:edit, :normal=>:normal, :template=>:template } #should be set in views
#DEFAULT_ITEM_VIEW = :link # should be set in card?
RENDERERS = { #should be defined in renderer
- :json => :JsonRenderer,
:email => :EmailHtml,
:txt => :Text
}
@@ -28,9 +30,6 @@ class Renderer
@@error_codes = {}
@@view_tags = {}
- attr_reader :format, :card, :root, :parent
- attr_accessor :form, :main_content, :error_status
-
class << self
def get_renderer format
@@ -110,7 +109,7 @@ def template
def method_missing method_id, *args, &proc
proc = proc {|*a| raw yield *a } if proc
- #warn "mmiss #{self.class}, #{card.name}, #{method_id}"
+ #Rails.logger.warn "mmiss #{self.class}, #{@card.inspect}, #{caller[0]}, #{method_id}"
response = template.send method_id, *args, &proc
String===response ? template.raw( response ) : response
end
@@ -336,7 +335,7 @@ def process_inclusion tcard, opts
opts[:home_view] = [:closed, :edit].member?(view) ? :open : view
# FIXME: special views should be represented in view definitions
-
+
view = case
when @mode == :edit
if @@perms[view]==:none || tcard.hard_template || tcard.key.blank? # eg {{_self|type}} on new cards
@@ -348,7 +347,7 @@ def process_inclusion tcard, opts
when @@perms[view]==:none ; view
when @mode == :closed ; !tcard.known? ? :closed_missing : :closed_content
else ; view
- end
+ end
result = sub.render(view, opts)
Renderer.current_slot = oldrenderer
@@ -456,7 +455,6 @@ def add_name_context name=nil
end
-
class Renderer::Html < Renderer ; end
class Renderer::File < Renderer ; end
@@ -466,7 +464,7 @@ class Renderer::Csv < Renderer::Text ; end
class Renderer::Css < Renderer::Text ; end
class Renderer::Data < Renderer ; end
- class Renderer::JsonRenderer < Renderer::Data ; end
+ class Renderer::Json < Renderer::Data ; end
@ethn Collaborator
ethn added a note

the issue here was when we had the json renderer in a separate file (which I think we really want). I'm now thinking we should do a lot less auto loading, which could solve this. In any case, this is fine for now, because at least it's more consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
class Renderer::Xml < Renderer::Data ; end
end
View
2  lib/wql.rb
@@ -259,7 +259,7 @@ def revision_spec(field, linkfield, val)
end
def found_by(val)
- cards = (String===val ? [ Card.fetch( absolute_name(val), :new=>{} ) ] : Wql.new(val).run)
+ cards = ( String===val ? [ Card.fetch( absolute_name(val), :new=>{} ) ] : Wql.new(val).run )
cards.each do |c|
raise %{"found_by" value needs to be valid Search card #{c.inspect}} unless c && [Card::SearchTypeID,Card::SetID].include?(c.type_id)
found_by_spec = CardSpec.new(c.get_spec).rawspec
View
27 spec/controllers/admin_controller_spec.rb
@@ -0,0 +1,27 @@
+require File.expand_path('../spec_helper', File.dirname(__FILE__))
+
+describe AdminController, "admin functions" do
+ before do
+ Account.as_bot do
+ Card.search(:type => Card::UserID).each do |card|
+ card.destroy
+ end
+ end
+ end
+
+ it "should setup be ready to setup" do
+ post :setup, :account => {:email=>'admin@joe'}
+ end
+
+ it "should clear cache" do
+ Account.as :joe_user do
+ get :clear_cache
+ end
+ end
+
+ it "should show cache" do
+ Account.as :joe_user do
+ get :show_cache, :id=>"A"
+ end
+ end
+end
View
50 spec/controllers/location_spec.rb
@@ -0,0 +1,50 @@
+require File.expand_path('../spec_helper', File.dirname(__FILE__))
+include AuthenticatedTestHelper
+
+describe CardController, "location test from old integration" do
+
+ include LocationHelper
+
+ before do
+ login_as 'joe_user'
+ end
+
+ it "should test_previous_location_should_be_assigned_after_viewing" do
+ get :read, :id=>"Joe_User"
+ assert_equal "/Joe_User", assigns['previous_location']
+ end
+
+ it "should test_previous_location_should_not_be_updated_by_nonexistent_card" do
+ get :read, :id=>"Joe_User"
+ get :read, :id=>"Not_Me"
+ get :read, :id=>'*previous'
+ assert_redirected_to '/Joe_User'
+ end
+
+ it "should test_return_to_special_url_when_logging_in_after_visit" do
+ # not sure this still tests the case, controller tests do not test routes
+ get :read, :id=>'*recent'
+ assert_equal "/*recent", assigns['previous_location']
+ end
+
+ # FIXME: this should probably be files in the spot for a delete test
+ it "should test_removal_and_return_to_previous_undeleted_card_after_deletion" do
+ t1 = t2 = nil
+ Account.as_bot do
+ t1 = Card.create! :name => "Testable1", :content => "hello"
+ t2 = Card.create! :name => "Testable1+bandana", :content => "world"
+ end
+
+ get :read, :id => t1.key
+ get :read, :id => t2.key
+
+ post :delete, :id=> '~'+t2.id.to_s
+ assert_nil Card[ t2.name ]
+ assert_redirected_to "/#{t1.name}"
+
+ post :delete, :id => '~'+t1.id.to_s
+ assert_redirected_to '/'
+ assert_nil Card[ t1.name ]
+ end
+
+end
View
130 spec/controllers/sets_spec.rb
@@ -0,0 +1,130 @@
+
+require File.expand_path('../spec_helper', File.dirname(__FILE__))
+include AuthenticatedTestHelper
+
+describe CardController do
+ it "module exists and autoloads" do
+ Wagn::Sets.should be_true
+ end
+
+ describe "read all set" do
+ it "gets data" do
+ get :read, :id=>'a'
+ end
+ end
+
+ describe ".process_read" do
+ before do
+ end
+
+ it "invokes actions on matching cards" do
+ end
@GerryG Collaborator
GerryG added a note

Need to fill in a few cases here ...

@ethn Collaborator
ethn added a note

we don't actually have any functionality here yet, right?

I'm not totally clear on what we want in the realm of read-triggered actions yet. We should probably gather some use cases. Any in particular live for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+ it "does not invoke actions on non-matching cards" do
+ end
+
+ it "invokes actions for set names" do
+
+ end
+
+ it "invokes multiple registered actions with arguments" do
+ end
+ end
+end
+
+
+describe CardController, "Basic rendering tests" do
+
+ before do
+ @sample_cards = Card.where("cards.key like 'sample_%' and cards.key not like '%+%'")
+ end
+
+ #these tests are increasingly lame.
+ # how about we actually test for presense of a few things ?
+
+ describe "for anonymous" do
+ before do
+ login_as :anonymous
+ end
+
+ it "should get changes for basic" do
+ card = Card['Sample Basic']
+ card.new_card?.should be_false
+ get :read, :id => "~#{card.id}", :view=>'changes'
+ assert_response :success
+ end
+
+ it "should read all types" do
+ @sample_cards.each do |sample|
+ get :read, :id => "~#{sample.id}"
+ assert_response :success
+ end
+ end
+
+ it "should get options for all types" do
+ @sample_cards.each do |sample|
+ get :read, :id => "~#{sample.id}", :view=>'options'
+ assert_response :success
+ end
+ end
+
+ it "should get edit form for all types" do
+ @sample_cards.each do |sample|
+ get :read, :id => "~#{sample.id}", :view=>'edit'
+ assert_response :forbidden
+ end
+ end
+
+ it "should get new for basic" do
+ get :read, :view=>'new'
+ assert_response :forbidden
+ end
+ end
+
+ describe "for joe user" do
+ before do
+ login_as 'Joe User'
+ end
+
+ it "should get changes for basic" do
+ get :read, :id => "~#{Card['Sample Basic'].id}", :view=>'changes'
+ assert_response :success
+ end
+
+ it "should read all types" do
+ @sample_cards.each do |sample|
+ get :read, :id => "~#{sample.id}"
+ assert_response :success
+ end
+ end
+
+ it "should get options for all types" do
+ @sample_cards.each do |sample|
+ get :read, :id => "~#{sample.id}", :view=>'options'
+ assert_response :success
+ end
+ end
+
+ it "should get edit form for all types" do
+ @sample_cards.each do |sample|
+ if %w{sample_html sample_layout}.member? sample.key
+ login_as 'Joe Admin' do
+ get :read, :id => "~#{sample.id}", :view=>'edit'
+ end
+ else
+ get :read, :id => "~#{sample.id}", :view=>'edit'
+ end
+ response.should be_success, "Getting #{sample.inspect}"
+ end
+ end
+
+ it "should get new for basic" do
+ get :read, :id=>'', :view=>'new'
+ assert_response :success
+ end
+
+ end
+
+end
+
+
View
2  spec/lib/cardlib/fetch_spec.rb
@@ -160,7 +160,7 @@
end
end
- describe "#fetch :new=> ..." do
+ describe "#fetch :new=>{ ... }" do
it "returns a new card if it doesn't find one" do
new_card = Card.fetch "Never Seen Me Before", :new=>{}
new_card.should be_instance_of(Card)
View
2  spec/lib/cardlib/permissions_spec.rb
@@ -135,7 +135,7 @@
it "should insure that class overrides work with relative settings" do
Account.as_bot do
- all_plus = Card.fetch '*all plus+*read', :new=>{:content=>'_left'}
+ all_plus = Card.fetch '*all plus+*read', :new => { :content=>'_left' }
all_plus.save
Account.as_bot { @perm_card.save! }
c = Card.create(:name=>'Home+Heart')
View
1  spec/lib/wagn/renderer_spec.rb
@@ -610,7 +610,6 @@ def controller
def slot_link card, format=:html
renderer = Wagn::Renderer.new card, :format=>format
renderer.add_name_context
- #Rails.logger.warn "slat lk #{card.name},#{renderer}, #{format}"
result = renderer.render :content
m = result.match(/<(cardlink|link|a) class.*<\/(cardlink|link|a)>/)
(m.to_s != "") ? m.to_s : result
View
4 spec/lib/wagn/set/all/json_spec.rb
@@ -5,7 +5,7 @@
describe Wagn::Set::All::Json, "JSON pack" do
context "status view" do
it "should handle real and virtual cards" do
- r = Wagn::Renderer::JsonRenderer
+ r = Wagn::Renderer::Json
real_json = r.new(Card['T'])._render_show :view=>:status
JSON[real_json].should == {"key"=>"t","status"=>"real","id"=>Card['T'].id, 'url_key'=>'T'}
virtual_json = r.new(Card.fetch('T+*self'))._render_show :view=>:status
@@ -14,7 +14,7 @@
it "should treat both unknown and unreadable cards as unknown" do
Account.as Card::AnonID do
- r = Wagn::Renderer::JsonRenderer
+ r = Wagn::Renderer::Json
unknown = Card.new :name=>'sump'
unreadable = Card.new :name=>'kumq', :type=>'Fruit'
View
40 spec/models/card/account_spec.rb
@@ -0,0 +1,40 @@
+require File.expand_path('../../spec_helper', File.dirname(__FILE__))
+
+describe Card, "account functions" do
+ before(:each) do
+ Account.current_id= Card['joe_user'].id
+ @auth_card = Account.current
+ #warn "auth is #{@auth_card.inspect}"
+ end
+
+ it "should not show account for link on user's card (allready has an account)" do
+ # render rules menu
+ rendered = Wagn::Renderer::Html.new(@auth_card).render_options
+ rendered.should_not match("Add a sign-in account for")
+ end
+
+ it "should not show account for link on another user's card (allready has an account)" do
+ # render rules menu
+ Account.current_id= Card['joe_admin'].id
+ rendered = Wagn::Renderer::Html.new(@auth_card).render_options
+ rendered.should_not match("Add a sign-in account for")
+ end
+
+ it 'should show for card without "accountable" on' do
+ rendered = Wagn::Renderer::Html.new(Card['A']).render_options
+ rendered.should_not match("Add a sign-in account for")
+ end
+
+ it 'should show for card with "accountable" on' do
+ Account.as_bot do
+ Card.create :name=>'A+*self+*accountable', :content=>'1'
+ Card.create :name=>'*account+*right+*create', :content=>'[[Anyone Signed In]]'
+ end
+ rendered = Wagn::Renderer::Html.new(Card['A']).render_options
+ rendered.should match("Add a sign-in account for")
+ end
+
+ it "should generate new password on forgotpassword" do
+ end
+
+end
View
3  spec/models/card/cardtype_spec.rb
@@ -38,7 +38,8 @@ class Card
assert_instance_of Card, c=Card.fetch("BananaPudding")
# you have to have a module to include or it's just a Basic (typecode fielde excepted)
- assert Card.create(:typecode=>'banana_pudding',:name=>"figgy" ).type_name == 'BananaPudding'
+ cd = Card.create(:type=>'banana_pudding',:name=>"figgy" )
+ assert cd.type_name == 'BananaPudding'
assert Card.find_by_type_id(c.id)
end
View
2  spec/models/card/trash_spec.rb
@@ -14,7 +14,7 @@
it "should come out of the trash when a plus card is created" do
Account.as_bot do
Card.create(:name=>'A+*acct')
- c = Card['A']
+ c = Card[ 'A' ]
c.trash.should be_false
end
end
View
4 spec/models/role_spec.rb
@@ -63,7 +63,9 @@
@roles_card.item_names.length.should==0
end
it "should immediately set new roles and return auth, anon, and the new one" do
- Account.as_bot { @roles_card << @r1 }
+ Account.as_bot do
+ @roles_card << @r1
+ end
@roles_card.item_names.length.should==1
end
it "should save new roles and reload correctly" do
View
0  test/functional/.gitkeep
No changes.
View
119 test/functional/account_controller_test.rb
@@ -1,119 +0,0 @@
-# -*- encoding : utf-8 -*-
-require File.expand_path('../test_helper', File.dirname(__FILE__))
-require 'account_controller'
-
-# Re-raise errors caught by the controller.
-class AccountController; def rescue_action(e) raise e end; end
-
-class AccountControllerTest < ActionController::TestCase
- # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead
- # Then, you can remove it from this and the units test.
- include AuthenticatedTestHelper
-
- # Note-- account creation is handled in it's own file account_creation_test
-
-
- def setup
- super
- new_renderer
- @controller = AccountController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
-
- @newby_email = 'newby@wagn.net'
- @newby_args = {:account=>{ :email=>@newby_email },
- :card=>{ :name=>'Newby Dooby' }}
- Account.as_bot do
- Card.create(:name=>'Account Request+*type+*captcha', :content=>'0')
- end
- signout
- end
-
- def test_should_login_and_redirect
- post :signin, :login => 'u3@user.com', :password => 'u3_pass'
- assert session[:user]
- assert_response :redirect
- end
-
- def test_should_fail_login_and_not_redirect
- post :signin, :login => 'webmaster@grasscommons.org', :password => 'bad password'
- assert_nil session[:user]
- assert_response 403
- end
-
- def test_should_signout
- get :signout
- assert_nil session[:user]
- assert_response :redirect
- end
-
- def test_create_successful
- integration_login_as 'joe_user', true
- #login_as 'joe_user'
- assert_difference ActionMailer::Base.deliveries, :size do
- assert_new_account do
- post_invite
- end
- end
- end
-
- def test_signup_form
- get :signup
- assert_response 200
- end
-
- def test_signup_with_approval
- post :signup, @newby_args
-
- assert_response :redirect
- assert Card['Newby Dooby'], "should create User card"
- assert_status @newby_email, 'pending'
-
- integration_login_as 'joe_admin', true
- post :accept, :card=>{:key=>'newby_dooby'}, :email=>{:subject=>'hello', :message=>'world'}
- assert_response :redirect
- assert_status @newby_email, 'active'
- end
-
- def test_signup_without_approval
- Account.as_bot do #make it so anyone can create accounts (ie, no approval needed)
- create_accounts_rule = Card['*account+*right'].fetch(:trait=>:create)
- create_accounts_rule << Card::AnyoneID
- create_accounts_rule.save!
- end
- post :signup, @newby_args
- assert_response :redirect
- assert_status @newby_email, 'active'
- end
-
- def test_dont_let_blocked_user_signin
- u = User.find_by_email('u3@user.com')
- u.blocked = true
- u.save
- post :signin, :login => 'u3@user.com', :password => 'u3_pass'
- assert_response 403
- assert_template ('signin')
- end
-
- def test_forgot_password
- post :forgot_password, :email=>'u3@user.com'
- assert_response :redirect
- end
-
- def test_forgot_password_not_found
- post :forgot_password, :email=>'nosuchuser@user.com'
- assert_response 404
- end
-
- def test_forgot_password_blocked
- email = 'u3@user.com'
- Account.as_bot do
- u = User.find_by_email(email)
- u.status = 'blocked'
- u.save!
- end
- post :forgot_password, :email=>email
- assert_response 403
- end
-
-end
View
137 test/functional/account_creation_test.rb
@@ -1,137 +0,0 @@
-# -*- encoding : utf-8 -*-
-require File.expand_path('../test_helper', File.dirname(__FILE__))
-require 'account_controller'
-
-# Re-raise errors caught by the controller.
-class AccountController; def rescue_action(e) raise e end; end
-
-class AccountCreationTest < ActionController::TestCase
- # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead
- # Then, you can remove it from this and the units test.
-
- include AuthenticatedTestHelper
-
-
-
- #FIXME - couldn't get this stuff to work in setup, but that's where it belongs.
- signed_in = Card[Card::AuthID]
- # need to use: Card['*account'].ok?(:create)
- #if (tasks_card=Card.fetch( !signed_in.fetch(:trait=>:task_list), :new=>{} )).
- # item_names.member?('create_accounts')
- # tasks_card << 'create_accounts'
- #end
-
- def setup
- super
- new_renderer
- @controller = AccountController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- #login_as 'joe_admin'
- integration_login_as 'joe_admin', true
- Wagn::Cache.restore
- end
-
-# this is working in interface but I can't get it to work here:
-=begin
- def test_should_require_valid_cardname
-# assert_raises(ActiveRecord::RecordInvalid) do
- assert_no_new_account do
- post_invite :card => { :name => "Joe+User/" }
- end
- end
-=end
-
- def test_should_create_account_from_account_request
- assert_equal :account_request, (c=Card.fetch('Ron Request')).typecode
- post_invite :card=>{ :key=>"ron_request"}, :action=>:accept
- c=Card.fetch('Ron Request')
- assert_equal :user, c.typecode
- assert_equal "active", User.find_by_email("ron@request.com").status
- end
-
- def test_should_create_account_from_account_request_when_user_hard_templated
- Account.as_bot { Card.create :name=>'User+*type+*structure', :content=>"like this" }
- assert_equal :account_request, (c=Card.fetch('Ron Request')).typecode
- post_invite :card=>{ :key=>"ron_request"}, :action=>:accept
- c=Card.fetch('Ron Request')
- assert_equal :user, c.typecode
- assert_equal "active", User.find_by_email("ron@request.com").status
- end
-
-
- def test_create_permission_denied_if_not_logged_in
- signout
- post "signout"
- assert_no_new_account do
-# assert_raises(Card::PermissionDenied) do
- post_invite
- end
- end
-
-
-
- def test_should_create_account_from_scratch
- assert_difference ActionMailer::Base.deliveries, :size do
- assert_new_account do
- post_invite
- assert_response 302
- end
- end
- email = ActionMailer::Base.deliveries[-1]
- # emails should be 'from' inviting user
- assert_equal Account.user.email, email.from[0]
- assert_equal 'active', User.find_by_email('new@user.com').status
- assert_equal 'active', User.find_by_email('new@user.com').status
- end
-
- def test_should_create_account_when_user_cards_are_templated ##FIXME -- I don't think this actually catches the bug I saw.
- Account.as_bot { Card.create! :name=> 'User+*type+*structure'}
- assert_new_account do
- post_invite
- assert_response 302
- end
- end
-
- # should work -- we generate a password if it's nil
- def test_should_generate_password_if_not_given
- assert_new_account do
- post_invite
- assert !assigns(:account).password.blank?
- end
- end
-
- def test_should_require_password_confirmation_if_password_given
- assert_no_new_account do
- #assert_raises(ActiveRecord::RecordInvalid) do
- post_invite :account=>{ :password=>'tedpass' }
- #end
- end
- end
-
- def test_should_require_email
- assert_no_new_account do
- #assert_raises(ActiveRecord::RecordInvalid) do
- post_invite :account=>{ :email => nil }
- assert assigns(:card).errors[:email]
- #assert assigns(:account).errors[:email]
- assert_response :success
- #end
- end
- end
-
- def test_should_require_unique_email
- post_invite :account=>{ :email=>'duplor@user.com' }
- assert_no_new_account do
- post_invite :account=>{ :email=>'duplor@user.com' }
- end
- end
-
- def test_should_create_account_from_existing_user
- assert_difference ::User, :count do
- assert_no_difference Card.where(:type_id=>Card::UserID), :count do
- post_invite :card=>{ :name=>"No Count" }, :account=>{ :email=>"no@count.com" }
- end
- end
- end
-end
View
60 test/functional/account_request_test.rb
@@ -1,60 +0,0 @@
-# -*- encoding : utf-8 -*-
-require File.expand_path('../test_helper', File.dirname(__FILE__))
-require 'card_controller'
-
-# Re-raise errors caught by the controller.
-class CardController; def rescue_action(e) raise e end; end
-class AccountRequestTest < ActionController::TestCase
-
- include AuthenticatedTestHelper
-
- def setup
- super
- new_renderer
- @controller = CardController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
-
- Account.as_bot do
- Card.create(:name=>'Account Request+*type+*captcha', :content=>'0')
- end
- end
-
- def test_should_redirect_to_account_request_landing_card
- post :create, :account=>{:email=>"jamaster@jay.net"}, :card=>{
- :type=>"Account Request",
- :name=>"Word Third",
- :content=>"Let me in!"
- }
- assert_response 302
- end
-
- def test_should_create_account_request
- post :create, :account=>{:email=>"jamaster@jay.net"}, :card=>{
- :type=>"Account Request",
- :name=>"Word Third",
- :content=>"Let me in!"
- }
-
- @card = Card["Word Third"]
- @user = User[ @card.id ]
-
- assert_equal @card.typecode, :account_request
-
- # this now happens only when created via account controller
-
- #assert_instance_of ::User, @user
- #assert_equal 'jamaster@jay.net', @user.email
- #assert_equal 'request', @user.status
-
- end
-
- def test_should_delete_and_block_user
- login_as 'joe_admin'
- # FIXME: should test agains mocks here, instead of re-testing the model...
- post :delete, :id=>"~#{Card.fetch('Ron Request').id}"
- assert_equal nil, Card.fetch('Ron Request')
- assert_equal 'blocked', User.find_by_email('ron@request.com').status
- end
-
-end
View
0  test/integration/.gitkeep
No changes.
View
25 test/integration/account_test.rb
@@ -1,25 +0,0 @@
-# -*- encoding : utf-8 -*-
-require File.expand_path('../test_helper', File.dirname(__FILE__))
-
-require 'card_controller'
-
-class CardController
- def rescue_action(e) raise e end
-end
-
-
-class AccountTest < ActionController::IntegrationTest
- include LocationHelper
-
- def test_return_to_home_page_after_login
- post '/account/signin', :login=>'joe@user.com', :password=>'joe_pass'
- assert_redirected_to '/'
- end
-
- def test_return_to_special_url_when_logging_in_after_visit
- get '/recent'
- post '/account/signin', :login=>'joe@user.com', :password=>'joe_pass'
- assert_redirected_to '/*recent'
- end
-
-end
View
15 test/integration/basic_rendering_test.rb
@@ -1,15 +0,0 @@
-# -*- encoding : utf-8 -*-
-require File.expand_path('../test_helper', File.dirname(__FILE__))
-
-class BasicRenderingTest < ActionController::IntegrationTest
-
- #these tests are increasingly lame.
-
- test_render "card/changes/:id" , :users=>{ :anonymous=>200, :joe_user=>200 }
- test_render "card/read/:id" , :users=>{ :anonymous=>200, :joe_user=>200 }, :cardtypes=>:all
- test_render "card/options/:id" , :users=>{ :anonymous=>200, :joe_user=>200 }, :cardtypes=>:all
- # joe doesn't have permission to edit account_requests, so test edit as admin for now.
- # later should have cardtype-specific permissions settings
- test_render "card/edit/:id" , :users=>{ :anonymous=>403, :joe_admin=>200 }, :cardtypes=>:all
- test_render "card/new" , :users=>{ :anonymous=>403, :joe_user=>200 }
-end
View
131 test/integration/card_action_test.rb
@@ -1,131 +0,0 @@
-# -*- encoding : utf-8 -*-
-require File.expand_path('../test_helper', File.dirname(__FILE__))
-
-require 'card_controller'
-
-class CardController
- def rescue_action(e) raise e end
-end
-
-
-class CardActionTest < ActionController::IntegrationTest
-
- include LocationHelper
-
- def setup
- super
- setup_default_user
- integration_login_as 'joe_user'
- end
-
- # Has Test
- # ---------
- # card/delete
- # card/create
- # connection/create
- # card/comment
- #
- # FIXME: Needs Test
- # -----------
- # card/rollback
- # card/save_draft
- # connection/delete ??
-
- def test_comment
- Account.as_bot do
- Card.create :name=>'A+*self+*comment', :type=>'Pointer', :content=>'[[Anyone]]'
- end
- post "card/update/A", :card => { :comment=>"how come" }
- assert_response 302
- end
-
- def test_create_role_card
- integration_login_as 'joe_admin'
- post( 'card/create', :card=>{:content=>"test", :type=>'Role', :name=>"Editor"})
- assert_response 302
-
- assert Card['Editor'].type_id == Card::RoleID
- end
-
- def test_create_cardtype_card
- Account.as_bot {
- post( 'card/create','card'=>{"content"=>"test", :type=>'Cardtype', :name=>"Editor2"} )}
- assert_response 302
- assert Card['Editor2'].typecode == :cardtype
- end
-
- def test_create
- Account.as_bot {