Fix a few error messages

This commit is contained in:
Kamil Trzcinski 2016-12-20 23:17:32 +01:00
parent 70dcd45de2
commit 22a0567823
No known key found for this signature in database
GPG Key ID: 4505F5C7E12C6A5A
5 changed files with 14 additions and 18 deletions

View File

@ -0,0 +1,9 @@
module MattermostHelper
def mattermost_teams_options(teams)
teams_options = teams.map do |id, options|
[options['display_name'] || options['name'], id]
end
teams_options.compact.unshift(['Select team...', '0'])
end
end

11
copy.sh
View File

@ -1,11 +0,0 @@
#!/bin/bash
set -xe
# rsync --delete -av config/{routes.rb,routes,initializers,application.rb} zj-gitlab:/opt/gitlab/embedded/service/gitlab-rails/config/
rsync --delete -av lib/mattermost zj-gitlab:/opt/gitlab/embedded/service/gitlab-rails/lib
# rsync --delete -av vendor/{assets,gitignore,gitlab-ci-yml} zj-gitlab:/opt/gitlab/embedded/service/gitlab-rails/vendor/
# rsync --delete -av ../gitlab-shell/{bin,lib,spec,hooks} zj-gitlab:/opt/gitlab/embedded/service/gitlab-shell
#ssh gitlab-test 'cd /opt/gitlab/embedded/service/gitlab-rails && /opt/gitlab/embedded/bin/bundle install --deployment'
#ssh gitlab-test 'export NO_PRIVILEGE_DROP=true; export USE_DB=false; gitlab-rake assets:precompile'
ssh zj-gitlab gitlab-ctl restart

View File

@ -30,12 +30,12 @@ module Mattermost
json_response = JSON.parse(response.body)
unless response.success?
raise ClientError(json_response['message'] || 'Undefined error')
raise Mattermost::ClientError.new(json_response['message'] || 'Undefined error')
end
json_response
rescue JSON::JSONError
raise ClientError('Cannot parse response')
raise Mattermost::ClientError.new('Cannot parse response')
end
end
end

View File

@ -81,9 +81,9 @@ module Mattermost
def post(path, options = {})
self.class.post(path, options.merge(headers: @headers))
rescue HTTParty::Error => e
raise ConnectionError(e.message)
raise Mattermost::ConnectionError.new(e.message)
rescue Errno::ECONNREFUSED
raise ConnectionError
raise Mattermost::ConnectionError.new(e.message)
end
private

View File

@ -3,9 +3,6 @@ require 'spec_helper'
describe Mattermost::Team do
describe '#all' do
let(:user) { build(:user) }
subject { described_class.new(user) }
let(:response) do
[{
"id" => "xiyro8huptfhdndadpz8r3wnbo",
@ -22,6 +19,7 @@ describe Mattermost::Team do
"allow_open_invite" => false }]
end
subject { described_class.new(user) }
before do
allow(subject).to receive(:json_get).and_return(response)