Sha256: 3ecfb72903a91c63059c011710b0c99f49544fba4e17570be848e16d0ecbf60c

Contents?: true

Size: 1.63 KB

Versions: 3

Compression:

Stored size: 1.63 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

module Gritano::Core
  describe User do
    before(:all) do
      ActiveRecord::Base.establish_connection(YAML::load(File.open('spec/data/development.yml')))
    end

    describe "#access" do
      it "should return a string that represents a read access" do
        repo = double("Repo")
        user = User.new
        user.should_receive(:check_access).with(repo, :read).and_return(true)
        user.should_receive(:check_access).with(repo, :write).and_return(false)
        user.access(repo).should be == "read"
      end

      it "should return a string that represents a write access" do
        repo = double("Repo")
        user = User.new
        user.should_receive(:check_access).with(repo, :read).and_return(false)
        user.should_receive(:check_access).with(repo, :write).and_return(true)
        user.access(repo).should be == "write"
      end

      it "should return a string that represents a read and write access" do
        repo = double("Repo")
        user = User.new
        user.should_receive(:check_access).with(repo, :read).and_return(true)
        user.should_receive(:check_access).with(repo, :write).and_return(true)
        user.access(repo).should be == "read+write"
      end

      it "should return a null string when user doens't have access to the repository" do
        repo = double("Repo")
        user = User.new
        user.should_receive(:check_access).with(repo, :read).and_return(false)
        user.should_receive(:check_access).with(repo, :write).and_return(false)
        user.access(repo).should be == ""
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gritano-2.0.2 spec/gritano/core/user_spec.rb
gritano-2.0.1 spec/gritano/core/user_spec.rb
gritano-2.0.0 spec/gritano/core/user_spec.rb