Top Level Namespace

Defined Under Namespace

Modules: ActiveRecord, Applicat, Concerns, EnvironmentConfiguration, FactoryMethods, HtmlSelectorsHelpers, I18n, Likeable, Model, NavigationHelpers, UserCukeHelpers, Vendors, Voluntary, WithinHelpers, Wizard Classes: Ability, ApiConstraints, AppConfig, ApplicationController, ApplicationSerializer, Area, AreaUser, AreasController, Argument, ArgumentSerializer, ArgumentTopic, BasicUserSerializer, Column, Comment, CommentsController, CurrentUserSerializer, DeferredGarbageCollection, HistoryTracker, HomeController, IntegrationSessionsController, LayoutPresenter, Like, LikesController, List, ListItem, MongoDatabaseCleaner, MongoDbDocument, OmniauthCallbacksController, Organization, OrganizationsController, Page, PagesController, Presenter, Product, ProductsController, Profession, ProfessionsController, Project, ProjectUser, ProjectsController, ResourcePresenter, Result, ResultsController, StoriesController, Story, StorySerializer, Task, TaskSerializer, TasksController, TestMails, Thing, User, UserSerializer, UsersController, Wikidata, WorkflowController

Instance Method Summary collapse

Instance Method Details

#r_strObject



1
2
3
# File 'lib/generators/voluntary/install/templates/spec/factories.rb', line 1

def r_str
  SecureRandom.hex(3)
end

#resource_has_many(resource, association_name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/generators/voluntary/install/templates/spec/factories.rb', line 5

def resource_has_many(resource, association_name)
  association = if resource.send(association_name).length > 0
    nil
  elsif association_name.to_s.classify.constantize.count > 0
    association_name.to_s.classify.constantize.last
  else
    Factory.create association_name.to_s.singularize.to_sym
  end
  
  resource.send(association_name).send('<<', association) if association
end