• Alex Kalderimis's avatar
    Add event creation support in wiki services · 50e4641c
    Alex Kalderimis authored
    This ensures that events are created when wiki pages are
    created/updated/destroyed in the app.
    
    This does not add events for wiki pages edited off-line and then
    published using git-access.
    
    The wiki page base service is the place where WikiPageMeta objects are
    constructed, leaving the logic in `EventCreateService#wiki_event` very
    thin. For this reason the two related changes are contained in a
    transaction.
    
    We also refactor wiki services to avoid passing statically known
    parameters. This is a more OOO conformant design, with fewer branches
    and if statements. The different kinds of actions are distinguished,
    with three actions:
     - external_action (used in the webhook)
     - usage_counter_action (used in the counter)
     - event_action (stored in events)
    
    These have (potentially) different values and different types.
    
    This interface in WikiPages::BaseService is enforced by implementing
    the three methods inheriting classes must override.
    
    We also place feature flag checks around more use sites. This ensures
    that we do not create wiki page events if the flag is turned off, and
    that we do not filter for them either.
    
    Includes suggested changes from reviewer (@.luke)
    
    Co-authored-by: @.luke
    
    Incidental chang: Less dynamic queries
    
    This passes class names for polymorphic types as constant strings. We do
    this because these strings are persisted to the database, and changes to
    the application need to keep previously stored values in mind. Any
    updates to the WikiPage::Meta class name need to ensure that values
    stored with `"WikiPage::Meta"` as target_type will still be around.
    50e4641c
events_spec.rb 8.03 KB