Module: SocialStream::TestHelpers::Controllers
- Defined in:
- lib/social_stream/test_helpers/controllers.rb
Instance Method Summary collapse
- #attributes ⇒ Object
-
#demodulized_model_sym ⇒ Object
:client for Site::ClientsController.
- #model_assigned_to(contact, relation_ids) ⇒ Object
-
#model_attributes ⇒ Object
Factory.attributes_for(:post) for PostsController.
-
#model_class ⇒ Object
Post for PostsController.
-
#model_count ⇒ Object
Post.count.
-
#model_sym ⇒ Object
:post for PostsController.
- #updating_attributes ⇒ Object
Instance Method Details
#attributes ⇒ Object
28 29 30 |
# File 'lib/social_stream/test_helpers/controllers.rb', line 28 def attributes { model_sym => model_attributes } end |
#demodulized_model_sym ⇒ Object
:client for Site::ClientsController
17 18 19 20 |
# File 'lib/social_stream/test_helpers/controllers.rb', line 17 def demodulized_model_sym @demodulized_model_sym ||= model_class.to_s.demodulize.underscore.to_sym end |
#model_assigned_to(contact, relation_ids) ⇒ Object
41 42 43 44 |
# File 'lib/social_stream/test_helpers/controllers.rb', line 41 def model_assigned_to contact, relation_ids model_attributes[:owner_id] = contact.receiver.id model_attributes[:relation_ids] = Array(relation_ids).map(&:id) end |
#model_attributes ⇒ Object
Factory.attributes_for(:post) for PostsController
23 24 25 26 |
# File 'lib/social_stream/test_helpers/controllers.rb', line 23 def model_attributes @model_attributes ||= Factory.attributes_for(model_sym) end |
#model_class ⇒ Object
Post for PostsController
5 6 7 8 |
# File 'lib/social_stream/test_helpers/controllers.rb', line 5 def model_class @model_class ||= described_class.to_s.sub!("Controller", "").singularize.constantize end |
#model_count ⇒ Object
Post.count
37 38 39 |
# File 'lib/social_stream/test_helpers/controllers.rb', line 37 def model_count model_class.count end |
#model_sym ⇒ Object
:post for PostsController
11 12 13 14 |
# File 'lib/social_stream/test_helpers/controllers.rb', line 11 def model_sym @model_sym ||= model_class.to_s.underscore.to_sym end |
#updating_attributes ⇒ Object
32 33 34 |
# File 'lib/social_stream/test_helpers/controllers.rb', line 32 def updating_attributes attributes.merge({ :id => @current_model.to_param }) end |