Module: SocialStream::TestHelpers::Controllers

Defined in:
lib/social_stream/test_helpers/controllers.rb

Instance Method Summary collapse

Instance Method Details

#attributesObject



22
23
24
# File 'lib/social_stream/test_helpers/controllers.rb', line 22

def attributes
  { model_sym => model_attributes }
end

#model_assigned_to(contact, relation_ids) ⇒ Object



35
36
37
38
39
40
# File 'lib/social_stream/test_helpers/controllers.rb', line 35

def model_assigned_to contact, relation_ids
  model_attributes[:author_id] = contact.sender.id
  model_attributes[:owner_id]  = contact.receiver.id
  model_attributes[:user_author_id] = contact.sender.id
  model_attributes[:_relation_ids] = Array(relation_ids).map(&:id)
end

#model_attributesObject

Factory.attributes_for(:post) for PostsController



17
18
19
20
# File 'lib/social_stream/test_helpers/controllers.rb', line 17

def model_attributes
  @model_attributes ||=
    Factory.attributes_for(model_sym)
end

#model_classObject

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_countObject

Post.count



31
32
33
# File 'lib/social_stream/test_helpers/controllers.rb', line 31

def model_count
  model_class.count
end

#model_symObject

: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_attributesObject



26
27
28
# File 'lib/social_stream/test_helpers/controllers.rb', line 26

def updating_attributes
  attributes.merge({ :id => @current_model.to_param })
end