Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 36 lines (29 sloc) 0.96 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
require 'spec_helper'

describe Api::V3::JSON::Tickets, :type => :api do
  let(:project) { Factory(:project) }
  let(:user) { Factory(:user) }
  let(:token) { user.authentication_token }

  before do
    Factory(:ticket, :project => project)
    user.permissions.create!(:thing => project, :action => "view")
  end

  let(:url) { "/api/v3/json/projects/#{project.id}/tickets" }

  context "successful requests" do

    it "can get a list of tickets" do
      get url, :token => token
      last_response.body.should eql(project.tickets.to_json)
    end
  end
  
  context "unsuccessful requests" do
    it "doesn't pass through a token" do
      get url
      last_response.status.should eql(401)
      last_response.body.should eql("Token is invalid.")
    end

    it "cannot access a project that they don't have permission to" do
      user.permissions.delete_all
      get url, :token => token
      last_response.status.should eql(404)
    end
  end
end
Something went wrong with that request. Please try again.