summaryrefslogtreecommitdiff
path: root/spec/models/user_spec.rb
blob: 44b260b358f986a8152fc31e2e56d692e34d583f (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require 'spec_helper'

describe User do

  describe "has_developer_access?" do
    before do
      @user = User.new({})
    end

    let(:project_with_owner_access) do
      {
        "name" => "gitlab-shell",
        "permissions" => {
          "project_access" => {
            "access_level"=> 10,
            "notification_level" => 3
          },
          "group_access" => {
            "access_level" => 50,
            "notification_level" => 3
          }
        }
      }
    end

    let(:project_with_reporter_access) do
      {
        "name" => "gitlab-shell",
        "permissions" => {
          "project_access" => {
            "access_level" => 20,
            "notification_level" => 3
          },
          "group_access" => {
            "access_level" => 10,
            "notification_level" => 3
          }
        }
      }
    end

    it "returns false for reporter" do
      @user.stub(:project_info).and_return(project_with_reporter_access)

      @user.has_developer_access?(1).should be_false
    end

    it "returns true for owner" do
      @user.stub(:project_info).and_return(project_with_owner_access)

      @user.has_developer_access?(1).should be_true
    end
  end
end