Sha256: 98e6b36992cf203701a2ee5595fb37bad671f858dbb431452eb03d68f20d9de0

Contents?: true

Size: 1.91 KB

Versions: 16

Compression:

Stored size: 1.91 KB

Contents

require 'spec_helper'

module Hubstats
  describe UsersController, :type => :controller do
    routes { Hubstats::Engine.routes }

    describe "#index" do
      it "should show all of the users" do
        user2 = create(:user, :id => 101010, :login => "examplePerson1", :updated_at => Date.today)
        user1 = create(:user, :id => 202020, :login => "examplePerson2", :updated_at => Date.today)
        user3 = create(:user, :id => 303030, :login => "examplePerson3", :updated_at => Date.today)
        user4 = create(:user, :id => 404040, :login => "examplePerson4", :updated_at => Date.today)
        expect(Hubstats::User).to receive_message_chain("with_id.custom_order.paginate").and_return([user2, user3, user1, user4])
        get :index
        expect(response).to have_http_status(200)
      end
    end

    describe "#show" do
      it "should show the pull requests and deploys of specific user" do
        user = create(:user, :id => 101010, :login => "examplePerson", :updated_at => Date.today)
        repo = create(:repo, :updated_at => Date.today)
        pull1 = create(:pull_request, :user => user, :id => 202020, :updated_at => Date.today, :repo_id => repo.id)
        pull2 = create(:pull_request, :user => user, :id => 303030, :repo => pull1.repo, :updated_at => Date.today)
        deploy1 = create(:deploy, :user_id => 101010)
        deploy2 = create(:deploy, :user_id => 101010)
        comment1 = create(:comment, :user => user, :updated_at => Date.today)
        comment2 = create(:comment, :user => user, :updated_at => Date.today)
        get :show, id: "examplePerson"
        expect(assigns(:user)).to eq(user)
        expect(assigns(:user).pull_requests).to contain_exactly(pull1, pull2)
        expect(assigns(:user).deploys).to contain_exactly(deploy1, deploy2)
        expect(assigns(:user).comments).to contain_exactly(comment2, comment1)
        expect(response).to have_http_status(200)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
hubstats-0.7.7 spec/controllers/hubstats/users_controller_spec.rb
hubstats-0.7.6 spec/controllers/hubstats/users_controller_spec.rb
hubstats-0.7.5 spec/controllers/hubstats/users_controller_spec.rb
hubstats-0.7.4 spec/controllers/hubstats/users_controller_spec.rb
hubstats-0.7.3 spec/controllers/hubstats/users_controller_spec.rb
hubstats-0.7.2 spec/controllers/hubstats/users_controller_spec.rb
hubstats-0.7.1 spec/controllers/hubstats/users_controller_spec.rb
hubstats-0.7.0 spec/controllers/hubstats/users_controller_spec.rb
hubstats-0.6.0 spec/controllers/hubstats/users_controller_spec.rb
hubstats-0.5.12 spec/controllers/hubstats/users_controller_spec.rb
hubstats-0.5.11 spec/controllers/hubstats/users_controller_spec.rb
hubstats-0.5.10 spec/controllers/hubstats/users_controller_spec.rb
hubstats-0.5.9 spec/controllers/hubstats/users_controller_spec.rb
hubstats-0.5.7 spec/controllers/hubstats/users_controller_spec.rb
hubstats-0.5.6 spec/controllers/hubstats/users_controller_spec.rb
hubstats-0.5.5 spec/controllers/hubstats/users_controller_spec.rb