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

API proof of concept: forums#show #665

Open
wants to merge 33 commits into
base: rails4
Choose a base branch
from
Open

Commits on Jul 2, 2015

  1. API proof of concept: forums#show

      * route is /api/forums/:id (may be slug)
      * versioning is done via Accept header
      * views are built with jbuilder
      * authentication is done via session cookies (or whatever the
        host app is using)
    eostrom committed Jul 2, 2015
    Configuration menu
    Copy the full SHA
    780197a View commit details
    Browse the repository at this point in the history

Commits on Jul 7, 2015

  1. Configuration menu
    Copy the full SHA
    2df1654 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f0520c1 View commit details
    Browse the repository at this point in the history

Commits on Jul 8, 2015

  1. JSON API compliance: relationships go inside data.

    Also abstracted some test code, in anticipation of including
    both topics and posts.
    eostrom committed Jul 8, 2015
    Configuration menu
    Copy the full SHA
    6080de5 View commit details
    Browse the repository at this point in the history
  2. Added posts count and views count.

    Posts count only includes posts the current user is allowed to know
    about.
    eostrom committed Jul 8, 2015
    Configuration menu
    Copy the full SHA
    676b2f6 View commit details
    Browse the repository at this point in the history

Commits on Jul 9, 2015

  1. Configuration menu
    Copy the full SHA
    1d8d680 View commit details
    Browse the repository at this point in the history

Commits on Jul 12, 2015

  1. Allow topics to be created without first posts.

    The standard UI automatically creates a post when a topic is created,
    but API-based UIs might not. Previously an error would be raised when
    creating a topic with no post, and also when approving it.
    
    Alternatively, if we want to require an initial post, we should
    add a validation.
    eostrom committed Jul 12, 2015
    Configuration menu
    Copy the full SHA
    7e8ad68 View commit details
    Browse the repository at this point in the history
  2. Give API routes priority.

    I ran into an issue where `/api/topics` was routed to
    TopicsController#index with a `forum_id` of `"api"`. With this
    change, `/api/` routes go to the API.
    
    This is a temporary fix, as it creates other problems if someone
    decides to start a forum called "API". We could add `api` to the
    reserved words list for Friendly ID, but some installations may
    already have an API forum. We could give the API routes a prefix that
    can't be generated by Friendly ID's default generator (e.g., `@api`).
    Or we could get rid of the prefix entirely, and just use the
    `Accepts` header to determine whether a request is for the HTML UI
    or the API.
    eostrom committed Jul 12, 2015
    Configuration menu
    Copy the full SHA
    c5a78c3 View commit details
    Browse the repository at this point in the history
  3. Create Topic happy path.

    This API controller inherits basic authorization and flow control from
    the HTML UI controller, and overrides methods to return results via
    JSON API. Alternatives include:
    
      1. Build all-new controllers for the API (as I started to do with
         forums), and remember to keep authorization and such in sync
         between the API and the HTML UI.
      2. Add API functionality directly to the HTML UI controllers,
         using `respond_to` and conditionals.
    
    Still evaluating these options.
    eostrom committed Jul 12, 2015
    Configuration menu
    Copy the full SHA
    88ca5e7 View commit details
    Browse the repository at this point in the history
  4. Create Topic error handling.

    Tried to cover all of the MUSTs and some of the SHOULDs from the JSON
    API spec.
    
    Specific errors are just returned as text messages for now.
    
    Most of the new controller code will be extracted to a mixin module.
    Likewise, the spec code can be extracted to shared behaviors.
    eostrom committed Jul 12, 2015
    Configuration menu
    Copy the full SHA
    aa614d9 View commit details
    Browse the repository at this point in the history

Commits on Jul 13, 2015

  1. Configuration menu
    Copy the full SHA
    87019aa View commit details
    Browse the repository at this point in the history

Commits on Jul 14, 2015

  1. API: Added topics#show.

    Also reworked TopicsController#find_topic so that (a) the API
    subclass can override the "not found" behavior, and (b) the method
    works as a `before_action` with slightly simpler code.
    eostrom committed Jul 14, 2015
    Configuration menu
    Copy the full SHA
    3b2ebb7 View commit details
    Browse the repository at this point in the history

Commits on Jul 15, 2015

  1. Configuration menu
    Copy the full SHA
    30d7dce View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a60d5d5 View commit details
    Browse the repository at this point in the history
  3. API: added posts#show.

    Also fixed an internal error when a post is submitted with no
    attributes.
    eostrom committed Jul 15, 2015
    Configuration menu
    Copy the full SHA
    3c867db View commit details
    Browse the repository at this point in the history

Commits on Jul 17, 2015

  1. Configuration menu
    Copy the full SHA
    95c9abf View commit details
    Browse the repository at this point in the history
  2. API: Added posts#update.

    Also moved some PostsController action code into `before_filter`s so
    that the API's own `before_filter`s get a chance to act.
    eostrom committed Jul 17, 2015
    Configuration menu
    Copy the full SHA
    dc751a3 View commit details
    Browse the repository at this point in the history
  3. Spec refactor: started abstracting API behavior.

    We now have a general notion of how create, update, and show requests
    behave, and can focus on the specifics of what data a successful
    request returns.
    
    Also made api/forums#show properly return 409 Forbidden.
    eostrom committed Jul 17, 2015
    Configuration menu
    Copy the full SHA
    054991a View commit details
    Browse the repository at this point in the history

Commits on Jul 19, 2015

  1. Configuration menu
    Copy the full SHA
    bafbee5 View commit details
    Browse the repository at this point in the history
  2. API: Inherit from ForumsController.

    This is the pattern we're using for the other controllers, to get
    permissions checking and such.
    
    Also removed unnecessary `respond_to` from `ForumsController#show`,
    and wrote a test to confirm that it was unnecessary.
    eostrom committed Jul 19, 2015
    Configuration menu
    Copy the full SHA
    b2684a8 View commit details
    Browse the repository at this point in the history

Commits on Jul 20, 2015

  1. API: Extracted JsonApiController module.

    Handles the routine mechanics of rendering the right responses.
    eostrom committed Jul 20, 2015
    Configuration menu
    Copy the full SHA
    5efb90f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    fe776c5 View commit details
    Browse the repository at this point in the history
  3. API: send user relationships, not ID attributes.

    Also implemented helpers for rendering relationship JSON.
    eostrom committed Jul 20, 2015
    Configuration menu
    Copy the full SHA
    b97d486 View commit details
    Browse the repository at this point in the history
  4. API: Render included posts with a partial.

    This reduces some code duplication, but as a result sends a little
    more info than necessary in the included post. If this is a problem,
    we can get around it by passing info to the partial about what
    relationships to reference.
    eostrom committed Jul 20, 2015
    Configuration menu
    Copy the full SHA
    45b8ef9 View commit details
    Browse the repository at this point in the history

Commits on Aug 18, 2015

  1. Configuration menu
    Copy the full SHA
    da075e8 View commit details
    Browse the repository at this point in the history

Commits on Aug 25, 2015

  1. API: Don't list unmoderated topics.

    Relies on the existing permission controls in the parent controller.
    eostrom committed Aug 25, 2015
    Configuration menu
    Copy the full SHA
    70e0ffe View commit details
    Browse the repository at this point in the history

Commits on Sep 8, 2015

  1. Merged from rails4 into api branch.

    Fixed routes conflict, and RSpec 3 deprecation warnings from the API
    specs.
    eostrom committed Sep 8, 2015
    Configuration menu
    Copy the full SHA
    92db379 View commit details
    Browse the repository at this point in the history

Commits on Sep 16, 2015

  1. Added created_at field to topics list.

    So the client can display a reasonable "last active" time for a
    topic with no posts.
    eostrom committed Sep 16, 2015
    Configuration menu
    Copy the full SHA
    0543130 View commit details
    Browse the repository at this point in the history

Commits on Sep 17, 2015

  1. Configuration menu
    Copy the full SHA
    21fa728 View commit details
    Browse the repository at this point in the history
  2. API: Include latest post author in topic list.

    ... by using the post partial instead of sending a subset of
    attributes.
    eostrom committed Sep 17, 2015
    Configuration menu
    Copy the full SHA
    6617ae2 View commit details
    Browse the repository at this point in the history
  3. API: Reduced code duplication in topic views.

    ... by extracting a partial with attributes and has-one
    relationships.
    eostrom committed Sep 17, 2015
    Configuration menu
    Copy the full SHA
    fbb1e72 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    5991286 View commit details
    Browse the repository at this point in the history

Commits on Sep 29, 2015

  1. Set last_post_at for topics with no posts.

    It's used as a proxy for "recent topics," so it makes sense to
    include new topics, even if they haven't received any replies.
    eostrom committed Sep 29, 2015
    Configuration menu
    Copy the full SHA
    b354f5b View commit details
    Browse the repository at this point in the history