Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action events #70

Merged
merged 127 commits into from
Jun 7, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
d07e537
a start
Dec 13, 2012
c6125e8
Merge branch 'reference_types' into action_events
Dec 13, 2012
ed18734
...
Dec 13, 2012
f9217b5
...
Dec 13, 2012
b4ac46b
mostly working
Dec 13, 2012
44bbc93
Pretty much all working, a few details, tests to move, coverage to ex…
Dec 13, 2012
fe39af9
Merge branch 'reference_types' into action_events
Dec 14, 2012
97f8820
Merge branch 'reference_types' into action_events
Dec 14, 2012
fd1bf88
Merge branch 'reference_types' into action_events
Dec 14, 2012
42c1fbe
Merge branch 'reference_types' into action_events
Dec 14, 2012
ad17ac9
Pull forward the move of test/functioin/* to specs, (not all working)
Dec 14, 2012
b7ef6cd
Not completely working, but many tests moved from test/*, basic event…
Dec 17, 2012
40c1713
All cuc passing, all test/functional and test/integration moved to specs
Dec 18, 2012
e21abf5
cherry-pick parts of action_events
Dec 19, 2012
34b1870
Merge ethan's pending branches forward (locations, menus_and_icons)
Dec 19, 2012
9e0b74e
Merge rebased parts forward
Dec 19, 2012
0a9eac4
make migrations work after merge
Dec 19, 2012
f06e682
...
Dec 19, 2012
0197f13
merge forward, just some notificatons broken now
Dec 24, 2012
b6f0f39
merge develop
Dec 24, 2012
801e1a7
Merge branch 'fix_tests' into action_develop
Dec 24, 2012
5632176
Merge branch 'reference_types' into action_reference
Dec 24, 2012
538b72a
merge reference_types
Dec 24, 2012
26317ef
Merge branch 'action_develop' into action_reference
Dec 26, 2012
9aeb486
Still working on merge, going back to merge forward
Jan 10, 2013
66ebbf0
merge load_cardlib into action_reference
Jan 10, 2013
a949f70
Merging obj_render into action_(events)reference (forward code with b…
Jan 10, 2013
1098be3
Merge obj_render again because I didn't have all the commits in my ob…
Jan 10, 2013
e987a58
merge aciton_reference to action_events
Jan 10, 2013
6626286
Merge branch 'load_cardlib' into action_events
Jan 10, 2013
1a5df99
Almost all working, breakthrough in loading actions
Jan 11, 2013
249ed12
Merge latest forward from load_cardlib through obj_render and clean u…
Jan 11, 2013
c8928c6
Merge obj_render
Jan 12, 2013
64df038
Add admin cards migration (codenames for routing cards)
Jan 12, 2013
16c729a
Revert the xml/json removal commit on json_xml branch
Jan 13, 2013
22d53a5
Merge branch 'obj_render' into json_xml
Jan 13, 2013
24f0289
Merge remote-tracking branch 'origin/obj_render' into json_xml
Jan 13, 2013
aa3e36e
merge forward (manually) the cleanup of the renderer calling code
Jan 13, 2013
de767b8
Merge some cleanups forward (adding back parts)
Jan 13, 2013
9a15bac
Merge branch 'obj_render' into json_xml
Jan 13, 2013
cc08cfb
revert removal (probably should just edit the commit to add it)
Jan 13, 2013
9a00cb8
Merge branch 'obj_render' into json_xml
Jan 13, 2013
6e77f75
Merge of obj_render into action_events (need json_xml too now)
Jan 14, 2013
c95b2bc
wip, action_events needs a bit of work
Jan 15, 2013
0c86ad2
Merge 1.10.3 forward
Jan 15, 2013
8900c74
Merge :session codename disable
Jan 15, 2013
ab74e10
merge
Jan 15, 2013
2b4c277
Merge branch 'obj_render' into action_events
Jan 15, 2013
16cb73c
Merge updates forward
Jan 17, 2013
0fce9ad
Merge obj_render
Jan 17, 2013
0763616
merge json_xml
Jan 17, 2013
dcc7045
Merge obj_content
Jan 17, 2013
14800e7
Merge branch 'json_xml' into action_events
Jan 17, 2013
3e4fe46
to_actions through obj_render to json_xml
Jan 17, 2013
1e85b22
Merge branch 'obj_render' into json_xml
Jan 17, 2013
cc9e816
Merge obj_content for new commits (to_actions)
Jan 17, 2013
13234a1
Merge branch 'obj_render' into json_xml
Jan 18, 2013
cab2b8c
Merge develop into action_events (to_actions and one from ethan)
Jan 18, 2013
c79d7fa
Merge to_actions forward via obj_render to json_xml
Jan 18, 2013
4053250
Merge forward to_actions
Jan 18, 2013
d1b8792
Double included removed
Jan 18, 2013
1ae9625
Merge branch 'obj_render' into json_xml
Jan 19, 2013
2908d25
Merge json_xml to action_events
Jan 19, 2013
05e3d68
Merge remote-tracking branch 'origin/action_events' into action_events
Jan 19, 2013
7dbf109
Merge branch 'obj_render' into json_xml
Jan 19, 2013
387af72
merge
Jan 19, 2013
6933dcc
Merge branch 'obj_render' into json_xml
Jan 20, 2013
9654f3a
Merge branch 'json_xml' into action_events
Jan 20, 2013
ba4c533
removing parts that should be just in admin_cards now
Jan 23, 2013
258105c
Remove json_xml parts
Jan 23, 2013
6de8ee6
Some card_controller cleanup
Jan 23, 2013
06f6018
Maybe ATP?
Jan 23, 2013
b3e4b43
Merge develop into action_events
Jan 26, 2013
54539da
...
Jan 26, 2013
80b5447
Merge branch 'develop' into action_events
Jan 26, 2013
752c188
Merge fixups
Jan 26, 2013
4b622c4
Merge remote-tracking branch 'origin/action_events' into action_events
Jan 26, 2013
2d6b8f3
Merge branch 'develop' into action_events
Jan 31, 2013
0c0302f
...
Jan 31, 2013
339166c
Merge branch 'simple_stuff' into action_events
Feb 1, 2013
6261454
Merge branch 'simple_stuff' into action_events
Feb 1, 2013
dd47f44
fix tests
Feb 1, 2013
0ced382
Merge branch 'simple_stuff' into action_events
Feb 1, 2013
13f355d
Merge branch 'develop' into action_events
Feb 1, 2013
acab66a
merge simple_stuff to action_events
Feb 2, 2013
3d49dd7
Merge branch 'develop' into action_events
Feb 3, 2013
2a15154
Merge branch 'css_fix' into action_events
Feb 7, 2013
fc7e9bb
fix account_spec with authorized -> current update
Feb 7, 2013
f9ea065
Merge branch 'css_fix' into action_events
Feb 7, 2013
a2be064
Merge develop
Feb 9, 2013
79607fb
Fix merge
Feb 9, 2013
51a695a
Merge branch 'develop' into action_events
Feb 9, 2013
3938637
Merge branch 'develop' into action_events
Feb 9, 2013
eddaf3c
Put aliases for base actions into sets definitions
Feb 10, 2013
44be492
Remove cardtype.rb, not needed anymore
Feb 10, 2013
49af216
Removing Renderer suffix from clasnames
Feb 17, 2013
6c4f788
Merge branch 'renderer_name' into action_events
Feb 17, 2013
be9cdf2
Merge Renderer suffix remove and expand it to HtmlRenderer too
Feb 17, 2013
f5a9768
Remove :css => text leftover code and remove extra warning
Feb 19, 2013
07ec1b7
Merge latest develop to action_events
Mar 1, 2013
c13dc7f
merge latest develop to action_events
Mar 2, 2013
f596cd4
Merge branch 'develop' into action_events
Mar 5, 2013
f6dcf43
Fix after merge
Mar 5, 2013
8b37052
Merge branch 'develop' into action_events
Mar 6, 2013
916850d
merge
Mar 9, 2013
478d517
Merge branch 'develop' into action_events
Mar 11, 2013
d042845
Merge tagged release
Mar 15, 2013
cc4869f
Merge branch 'develop' into action_events
Mar 24, 2013
680f294
Merge branch 'develop' into action_events
Mar 25, 2013
e310f9f
Merge branch 'develop' into action_events
Mar 27, 2013
55903c0
merge
Apr 27, 2013
70247a9
Merge remote-tracking branch 'origin/develop' into action_events
Apr 27, 2013
c3ef881
Merge branch 'develop' into action_events
May 1, 2013
bf592b4
added attr_* from develop (missed in merge)
May 2, 2013
701e933
Missed some code in first merge
May 2, 2013
5277c1e
Move status to renerder (from card) to fix remaining merge issue
May 2, 2013
2fcc4d5
Remove read_file
May 3, 2013
29be35c
...
May 4, 2013
6eee0ca
Merge branch 'develop' into action_events
May 10, 2013
fef61f3
Merge branch 'develop' into action_events
May 15, 2013
ce7f8c4
Merge remote-tracking branch 'origin/action_events' into action_events
May 15, 2013
c162a7a
Merge branch 'develop' into action_events
May 22, 2013
26e6fd3
Merge out old action stuff
Jun 6, 2013
558ed23
Remove a few changes we probably don't want
Jun 6, 2013
46b0141
Take pending away on 2 (they work)
Jun 6, 2013
da1bdf4
Merge branch 'develop' into action_events
Jun 6, 2013
900e6b4
Remove wrong test change
Jun 7, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/card/reference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ def repair_all
end

end

end
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 8 additions & 10 deletions lib/wagn/renderer.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- encoding : utf-8 -*-


module Wagn
class Renderer

Expand All @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -456,7 +455,6 @@ def add_name_context name=nil

end


class Renderer::Html < Renderer ; end

class Renderer::File < Renderer ; end
Expand All @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

class Renderer::Xml < Renderer::Data ; end

end
Expand Down
2 changes: 1 addition & 1 deletion lib/wql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions spec/controllers/admin_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -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
50 changes: 50 additions & 0 deletions spec/controllers/location_spec.rb
Original file line number Diff line number Diff line change
@@ -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
130 changes: 130 additions & 0 deletions spec/controllers/sets_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fill in a few cases here ...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?


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


2 changes: 1 addition & 1 deletion spec/lib/cardlib/fetch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/cardlib/permissions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
1 change: 0 additions & 1 deletion spec/lib/wagn/renderer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/wagn/set/all/json_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down
40 changes: 40 additions & 0 deletions spec/models/card/account_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Loading