Merge remote-tracking branch 'upstream/develop' into travis

This commit is contained in:
André Bauer 2016-10-24 10:38:25 +02:00
commit e07a4a3e3d
13 changed files with 113 additions and 66 deletions

View file

@ -13,7 +13,6 @@ Getting Started
--------------- ---------------
1. Install Zammad on your system 1. Install Zammad on your system
``` ```
root@shell> cd /opt/ root@shell> cd /opt/
root@shell> tar -xzf zammad-1.0.1.tar.gz root@shell> tar -xzf zammad-1.0.1.tar.gz
@ -22,7 +21,6 @@ Getting Started
``` ```
2. Install all dependencies 2. Install all dependencies
``` ```
zammad@shell> cd zammad zammad@shell> cd zammad
zammad@shell> gem install bundler zammad@shell> gem install bundler
@ -35,14 +33,12 @@ Getting Started
``` ```
3. Configure your databases 3. Configure your databases
``` ```
zammad@shell> cp config/database.yml.dist config/database.yml zammad@shell> cp config/database.yml.dist config/database.yml
zammad@shell> vi config/database.yml zammad@shell> vi config/database.yml
``` ```
4. Initialize your database 4. Initialize your database
``` ```
zammad@shell> export RAILS_ENV=production zammad@shell> export RAILS_ENV=production
zammad@shell> rake db:create zammad@shell> rake db:create
@ -51,7 +47,6 @@ Getting Started
``` ```
5. Change directory to zammad (if needed) and start the web server: 5. Change directory to zammad (if needed) and start the web server:
``` ```
zammad@shell> rake assets:precompile zammad@shell> rake assets:precompile
zammad@shell> rails s -p 3000 # application web server zammad@shell> rails s -p 3000 # application web server
@ -61,4 +56,3 @@ Getting Started
6. Go to http://localhost:3000/#getting_started and you'll see: 6. Go to http://localhost:3000/#getting_started and you'll see:
"Welcome to Zammad!", there you need to create your admin user and you need to invite other agents. "Welcome to Zammad!", there you need to create your admin user and you need to invite other agents.

View file

@ -15,9 +15,9 @@ Get Zammad
---------- ----------
````shell ````shell
test -d ~/zammad/ || mkdir ~/zammad test -d ~/zammad/ || mkdir ~/zammad
cd ~/zammad/ cd ~/zammad/
curl -L -O http://zammad.org/zammad-latest.tar.bz2 | tar -xj curl -L -O https://ftp.zammad.com/zammad-latest.tar.bz2 | tar -xj
```` ````
Install Zammad Install Zammad

View file

@ -14,7 +14,7 @@
### Get Zammad ### Get Zammad
* su zammad * su zammad
* cd ~ * cd ~
* wget http://ftp.zammad.com/zammad-latest.tar.gz * wget https://ftp.zammad.com/zammad-latest.tar.gz
* tar -xzf zammad-latest.tar.gz * tar -xzf zammad-latest.tar.gz
* exit * exit
@ -53,4 +53,3 @@
### Restart nginx as root ### Restart nginx as root
* exit * exit
* systemctl restart nginx * systemctl restart nginx

View file

@ -1,6 +1,6 @@
<div class="alert alert--danger hidden" role="alert"></div> <div class="alert alert--danger hidden" role="alert"></div>
<p> <p>
<%- @T('The tutorial on how to manage a %s is hosted on our [online documentation](http://zammad.org/documentation/channel/facebook).', 'Facebook App') %> <%- @T('The tutorial on how to manage a %s is hosted on our [online documentation](https://zammad.org/documentation/channel/facebook).', 'Facebook App') %>
</p> </p>
<fieldset> <fieldset>
<h2><%- @T('Enter your %s App Keys', 'Facebook') %></h2> <h2><%- @T('Enter your %s App Keys', 'Facebook') %></h2>
@ -26,4 +26,4 @@
<input class="form-control js-select" readonly value="<%= @callbackUrl %>"> <input class="form-control js-select" readonly value="<%= @callbackUrl %>">
</div> </div>
</div> </div>
</fieldset> </fieldset>

View file

@ -7,7 +7,7 @@
<h2>Ticket Article</h2> <h2>Ticket Article</h2>
<div class="ticketZoom"> <div class="ticketZoom">
<div class="scrollPageHeader tabsSidebar-sidebarSpacer" <div class="scrollPageHeader tabsSidebar-sidebarSpacer"
data-anchor-target=".ticketZoom .page-header" data-anchor-target=".ticketZoom .page-header"
data-128-top-bottom="transform: translateY(-64px);" data-128-top-bottom="transform: translateY(-64px);"
data-64-top-bottom="transform: translateY(0px);" data-64-top-bottom="transform: translateY(0px);"
@ -37,7 +37,7 @@
<h1 contenteditable="true" class="ticket-title-update" data-placeholder="Enter Title...">Welcome to Zammad! We want to entertain you and your whole family!</h1> <h1 contenteditable="true" class="ticket-title-update" data-placeholder="Enter Title...">Welcome to Zammad! We want to entertain you and your whole family!</h1>
</div> </div>
<div class="ticket-meta"> <div class="ticket-meta">
<small class="task-subline">Ticket# <span class="ticket-number">10001</span> - erstellte <span class="humanTimeFromNow" data-time="2014-07-11T10:10:32.000Z" title="11.07.2014 12:10">11.07.2014</span> <small class="task-subline">Ticket# <span class="ticket-number">10001</span> - erstellte <span class="humanTimeFromNow" data-time="2014-07-11T10:10:32.000Z" title="11.07.2014 12:10">11.07.2014</span>
</small> </small>
</div> </div>
</div> </div>
@ -65,12 +65,12 @@ Welcome!
<br/> <br/>
Thank you for installing Zammad.<br/> Thank you for installing Zammad.<br/>
<br/> <br/>
You will find updates and patches at <a href="http://zammad.org/" title="http://zammad.org/" target="_blank">http://zammad.org/</a>. Online<br/> You will find updates and patches at <a href="https://zammad.org/" title="https://zammad.org/" target="_blank">https://zammad.org/</a>. Online<br/>
documentation is available at <a href="http://guides.zammad.org/" title="http://guides.zammad.org/" target="_blank">http://guides.zammad.org/</a>. You can also<br/> documentation is available at <a href="https://zammad.org/documentation/" title="https://zammad.org/documentation/" target="_blank">https://zammad.org/documentation/</a>. Get involved<br/>
use our forums at <a href="http://forums.zammad.org/" title="http://forums.zammad.org/" target="_blank">http://forums.zammad.org/</a><br/> (discussions, contributing, ...) at <a href="https://zammad.org/participate" title="https://zammad.org/participate" target="_blank">https://zammad.org/participate</a>.<br/>
<br/> <br/>
Regards,<br/> Regards,<br/>
The <a href="http://Zammad.org" title="http://Zammad.org" target="_blank">Zammad.org</a> Project The <a href="https://zammad.org" title="https://zammad.org" target="_blank">zammad.org</a> Project
<div class="textBubble-overflowContainer"> <div class="textBubble-overflowContainer">
<div class="btn btn--text js-unfold"><%- @T('See more') %></div> <div class="btn btn--text js-unfold"><%- @T('See more') %></div>
</div> </div>
@ -105,7 +105,7 @@ The <a href="http://Zammad.org" title="http://Zammad.org" target="_blank">Zammad
<small class="task-subline"><time class="humanTimeFromNow" data-time="2014-07-11T10:10:32.000Z" title="2014-07-11 12:10">2014-07-11</time></small> <small class="task-subline"><time class="humanTimeFromNow" data-time="2014-07-11T10:10:32.000Z" title="2014-07-11 12:10">2014-07-11</time></small>
</div> </div>
<div class="ticket-article-item agent note" data-id="23" id="article-23"> <div class="ticket-article-item agent note" data-id="23" id="article-23">
<div class="article-meta-clip top"> <div class="article-meta-clip top">
<div class="article-content-meta top hide"> <div class="article-content-meta top hide">
<div class="article-meta top"> <div class="article-meta top">
@ -189,7 +189,7 @@ Grüße, Peter</div>
<small class="task-subline"><time class="humanTimeFromNow" data-time="2014-07-11T10:10:32.000Z" title="2014-07-11 12:10">2014-07-11</time></small> <small class="task-subline"><time class="humanTimeFromNow" data-time="2014-07-11T10:10:32.000Z" title="2014-07-11 12:10">2014-07-11</time></small>
</div> </div>
<div class="ticket-article-item agent note" data-id="23" id="article-23"> <div class="ticket-article-item agent note" data-id="23" id="article-23">
<div class="article-meta-clip top"> <div class="article-meta-clip top">
<div class="article-content-meta top hide"> <div class="article-content-meta top hide">
<div class="article-meta top"> <div class="article-meta top">
@ -274,4 +274,4 @@ Oliver<br>
</div> </div>
</div> </div>
</div> </div>

View file

@ -97,15 +97,15 @@
</div> </div>
<div> <div>
You will find updates and patches at <a href="http://zammad.org/" target="_blank" title="http://zammad.org/">http://zammad.org/</a>. Online You will find updates and patches at <a href="https://zammad.org/" target="_blank" title="https://zammad.org/">https://zammad.org/</a>. Online
</div> </div>
<div> <div>
documentation is available at <a href="http://guides.zammad.org/" target="_blank" title="http://guides.zammad.org/">http://guides.zammad.org/</a>. You can also documentation is available at <a href="https://zammad.org/documentation/" target="_blank" title="https://zammad.org/documentation/>https://zammad.org/documentation/</a>. You can also
</div> </div>
<div> <div>
use our forums at <a href="http://forums.zammad.org/" target="_blank" title="http://forums.zammad.org/">http://forums.zammad.org/</a> get involved (discussions, contributing, ...) at <a href="https://zammad.org/participate" target="_blank" title="https://zammad.org/participate">https://zammad.org/participate</a>.
</div> </div>
<div> <div>
@ -121,7 +121,7 @@
</div> </div>
<div> <div>
The <a href="http://Zammad.org" target="_blank" title="http://Zammad.org">Zammad.org</a> Project The <a href="https://zammad.org" target="_blank" title="https://zammad.org">zammad.org</a> Project
</div> </div>
<div class="textBubble-overflowContainer hide"> <div class="textBubble-overflowContainer hide">
@ -625,7 +625,7 @@
<option selected value="1"> <option selected value="1">
Users Users
</option> </option>
</select> </select>
</div><span class="help-inline"></span> <span class="help-block"></span> </div><span class="help-inline"></span> <span class="help-block"></span>
</div> </div>
</div> </div>
@ -649,7 +649,7 @@
<option selected value="4"> <option selected value="4">
Hans Huber Hans Huber
</option> </option>
</select> </select>
</div><span class="help-inline"></span> <span class="help-block"></span> </div><span class="help-inline"></span> <span class="help-block"></span>
</div> </div>
</div> </div>
@ -677,7 +677,7 @@
<option value="3"> <option value="3">
pending reminder pending reminder
</option> </option>
</select> </select>
</div><span class="help-inline"></span> <span class="help-block"></span> </div><span class="help-inline"></span> <span class="help-block"></span>
</div> </div>
</div> </div>
@ -717,7 +717,7 @@
<option value="3"> <option value="3">
3 high 3 high
</option> </option>
</select> </select>
</div><span class="help-inline"></span> <span class="help-block"></span> </div><span class="help-inline"></span> <span class="help-block"></span>
</div> </div>
</div> </div>
@ -896,7 +896,7 @@
<option value="3"> <option value="3">
pending pending
</option> </option>
</select> </select>
</div> </div>
<div class="form-group is-changed"> <div class="form-group is-changed">
@ -912,7 +912,7 @@
<option value="3"> <option value="3">
3 high 3 high
</option> </option>
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -932,7 +932,7 @@
<option selected value="1"> <option selected value="1">
Users Users
</option> </option>
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -944,7 +944,7 @@
<option value="3"> <option value="3">
Felix Niklas Felix Niklas
</option> </option>
</select> </select>
</div> </div>
</form> </form>
@ -954,4 +954,4 @@
</div> </div>
</form> </form>
</div> </div>
</div> </div>

View file

@ -27,7 +27,7 @@
</div> </div>
</div> </div>
<div class="scrollPageHeader tabsSidebar-sidebarSpacer" <div class="scrollPageHeader tabsSidebar-sidebarSpacer"
data-anchor-target=".ticketZoom .page-header" data-anchor-target=".ticketZoom .page-header"
data-128-top-bottom="transform: translateY(-64px);" data-128-top-bottom="transform: translateY(-64px);"
data-64-top-bottom="transform: translateY(0px);" data-64-top-bottom="transform: translateY(0px);"
@ -57,7 +57,7 @@
<h1 contenteditable="true" class="ticket-title-update" data-placeholder="Enter Title...">Welcome to Zammad! We want to entertain you and your whole family!</h1> <h1 contenteditable="true" class="ticket-title-update" data-placeholder="Enter Title...">Welcome to Zammad! We want to entertain you and your whole family!</h1>
</div> </div>
<div class="ticket-meta"> <div class="ticket-meta">
<small class="task-subline">Ticket# <span class="ticket-number">10001</span> - erstellte <span class="humanTimeFromNow" data-time="2014-07-11T10:10:32.000Z" title="11.07.2014 12:10">11.07.2014</span> <small class="task-subline">Ticket# <span class="ticket-number">10001</span> - erstellte <span class="humanTimeFromNow" data-time="2014-07-11T10:10:32.000Z" title="11.07.2014 12:10">11.07.2014</span>
</small> </small>
</div> </div>
</div> </div>
@ -86,12 +86,12 @@
<br/> <br/>
Thank you for installing Zammad.<br/> Thank you for installing Zammad.<br/>
<br/> <br/>
You will find updates and patches at <a href="http://zammad.org/" title="http://zammad.org/" target="_blank">http://zammad.org/</a>. Online<br/> You will find updates and patches at <a href="https://zammad.org/" title="https://zammad.org/" target="_blank">https://zammad.org/</a>. Online<br/>
documentation is available at <a href="http://guides.zammad.org/" title="http://guides.zammad.org/" target="_blank">http://guides.zammad.org/</a>. You can also<br/> documentation is available at <a href="https://zammad.org/documentation/" title="https://zammad.org/documentation/" target="_blank">https://zammad.org/documentation/</a>. Get involved<br/>
use our forums at <a href="http://forums.zammad.org/" title="http://forums.zammad.org/" target="_blank">http://forums.zammad.org/</a><br/> (discussions, contributing, ...) at <a href="https://zammad.org/participate" title="https://zammad.org/participate" target="_blank">https://zammad.org/participate</a>.<br/>
<br/> <br/>
Regards,<br/> Regards,<br/>
The <a href="http://Zammad.org" title="http://Zammad.org" target="_blank">Zammad.org</a> Project The <a href="https://zammad.org" title="https://zammad.org" target="_blank">zammad.org</a> Project
</div> </div>
<div class="textBubble-overflowContainer"> <div class="textBubble-overflowContainer">
<div class="btn btn--text js-unfold"><%- @T('See more') %></div> <div class="btn btn--text js-unfold"><%- @T('See more') %></div>
@ -130,7 +130,7 @@
<small class="task-subline"><time class="humanTimeFromNow" data-time="2014-07-11T10:10:32.000Z" title="2014-07-11 12:10">2014-07-11</time></small> <small class="task-subline"><time class="humanTimeFromNow" data-time="2014-07-11T10:10:32.000Z" title="2014-07-11 12:10">2014-07-11</time></small>
</div> </div>
<div class="ticket-article-item agent note" data-id="23" id="article-23"> <div class="ticket-article-item agent note" data-id="23" id="article-23">
<div class="article-meta-clip top"> <div class="article-meta-clip top">
<div class="article-content-meta top hide"> <div class="article-content-meta top hide">
<div class="article-meta top"> <div class="article-meta top">
@ -219,7 +219,7 @@
<small class="task-subline"><time class="humanTimeFromNow" data-time="2014-07-11T10:10:32.000Z" title="2014-07-11 12:10">2014-07-11</time></small> <small class="task-subline"><time class="humanTimeFromNow" data-time="2014-07-11T10:10:32.000Z" title="2014-07-11 12:10">2014-07-11</time></small>
</div> </div>
<div class="ticket-article-item agent note" data-id="23" id="article-23"> <div class="ticket-article-item agent note" data-id="23" id="article-23">
<div class="article-meta-clip top"> <div class="article-meta-clip top">
<div class="article-content-meta top hide"> <div class="article-content-meta top hide">
<div class="article-meta top"> <div class="article-meta top">
@ -655,4 +655,4 @@
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>

View file

@ -1,6 +1,6 @@
<div class="alert alert--danger hidden" role="alert"></div> <div class="alert alert--danger hidden" role="alert"></div>
<p> <p>
<%- @T('The tutorial on how to manage a %s is hosted on our [online documentation](http://zammad.org/documentation/channel/twitter).', 'Twitter App') %> <%- @T('The tutorial on how to manage a %s is hosted on our [online documentation](https://zammad.org/documentation/channel/twitter).', 'Twitter App') %>
</p> </p>
<fieldset> <fieldset>
<h2><%- @T('Enter your %s App Keys', 'Twitter') %></h2> <h2><%- @T('Enter your %s App Keys', 'Twitter') %></h2>
@ -26,4 +26,4 @@
<input class="form-control js-select" readonly value="<%= @callbackUrl %>"> <input class="form-control js-select" readonly value="<%= @callbackUrl %>">
</div> </div>
</div> </div>
</fieldset> </fieldset>

View file

@ -41,7 +41,7 @@ class Chat::Session < ApplicationModel
def position def position
return if state != 'waiting' return if state != 'waiting'
position = 0 position = 0
Chat::Session.where(state: 'waiting').order('created_at ASC').each { |chat_session| Chat::Session.where(state: 'waiting').order(created_at: :asc).each { |chat_session|
position += 1 position += 1
break if chat_session.id == id break if chat_session.id == id
} }
@ -52,7 +52,7 @@ class Chat::Session < ApplicationModel
chat_session = Chat::Session.find_by(session_id: session_id) chat_session = Chat::Session.find_by(session_id: session_id)
return if !chat_session return if !chat_session
session_attributes = [] session_attributes = []
Chat::Message.where(chat_session_id: chat_session.id).each { |message| Chat::Message.where(chat_session_id: chat_session.id).order(created_at: :asc).each { |message|
session_attributes.push message.attributes session_attributes.push message.attributes
} }
session_attributes session_attributes
@ -60,10 +60,10 @@ class Chat::Session < ApplicationModel
def self.active_chats_by_user_id(user_id) def self.active_chats_by_user_id(user_id)
actice_sessions = [] actice_sessions = []
Chat::Session.where(state: 'running', user_id: user_id).order('created_at ASC').each { |session| Chat::Session.where(state: 'running', user_id: user_id).order(created_at: :asc).each { |session|
session_attributes = session.attributes session_attributes = session.attributes
session_attributes['messages'] = [] session_attributes['messages'] = []
Chat::Message.where(chat_session_id: session.id).each { |message| Chat::Message.where(chat_session_id: session.id).order(created_at: :asc).each { |message|
session_attributes['messages'].push message.attributes session_attributes['messages'].push message.attributes
} }
actice_sessions.push session_attributes actice_sessions.push session_attributes

View file

@ -3029,9 +3029,9 @@ Ticket::Article.create(
Thank you for choosing Zammad. Thank you for choosing Zammad.
You will find updates and patches at http://zammad.org/. Online You will find updates and patches at https://zammad.org/. Online
documentation is available at http://zammad.org/documentation. Get documentation is available at https://zammad.org/documentation. Get
involved (discussions, contributing, ...) at http://zammad.org/participate. involved (discussions, contributing, ...) at https://zammad.org/participate.
Regards, Regards,
@ -5193,7 +5193,7 @@ Trigger.create_or_update(
<br/> <br/>
<div>Your #{config.product_name} Team</div> <div>Your #{config.product_name} Team</div>
<br/> <br/>
<div><i><a href="http://zammad.com">Zammad</a>, your customer support system</i></div>', <div><i><a href="https://zammad.com">Zammad</a>, your customer support system</i></div>',
'recipient' => 'ticket_customer', 'recipient' => 'ticket_customer',
'subject' => 'Thanks for your inquiry (#{ticket.title})', 'subject' => 'Thanks for your inquiry (#{ticket.title})',
}, },
@ -5232,7 +5232,7 @@ Trigger.create_or_update(
<br/> <br/>
<div>Your #{config.product_name} Team</div> <div>Your #{config.product_name} Team</div>
<br/> <br/>
<div><i><a href="http://zammad.com">Zammad</a>, your customer support system</i></div>', <div><i><a href="https://zammad.com">Zammad</a>, your customer support system</i></div>',
'recipient' => 'ticket_customer', 'recipient' => 'ticket_customer',
'subject' => 'Thanks for your follow up (#{ticket.title})', 'subject' => 'Thanks for your follow up (#{ticket.title})',
}, },
@ -5260,7 +5260,7 @@ Trigger.create_or_update(
<a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a> <a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
</p> </p>
<br/> <br/>
<p><i><a href="http://zammad.com">Zammad</a>, your customer support system</i></p>', <p><i><a href="https://zammad.com">Zammad</a>, your customer support system</i></p>',
'recipient' => 'ticket_customer', 'recipient' => 'ticket_customer',
'subject' => 'Owner has changed (#{ticket.title})', 'subject' => 'Owner has changed (#{ticket.title})',
}, },

View file

@ -6,8 +6,8 @@ class MaintenanceSessionMessageTest < TestCase
string = rand(99_999_999_999_999_999).to_s string = rand(99_999_999_999_999_999).to_s
title_html = "test <b>#{string}</b>" title_html = "test <b>#{string}</b>"
title_text = "test <b>#{string}<\/b>" title_text = "test <b>#{string}<\/b>"
message_html = "message <b>1äöüß</b> #{string}\n\n\nhttp://zammad.org" message_html = "message <b>1äöüß</b> #{string}\n\n\nhttps://zammad.org"
message_text = "message <b>1äöüß</b> #{string}\n\n\nhttp://zammad.org" message_text = "message <b>1äöüß</b> #{string}\n\n\nhttps://zammad.org"
# check #1 # check #1
browser1 = browser_instance browser1 = browser_instance

View file

@ -129,10 +129,10 @@ class AaaStringTest < ActiveSupport::TestCase
result = 'test' result = 'test'
assert_equal(result, html.html2text) assert_equal(result, html.html2text)
html = "\n<div><a href=\"http://zammad.org\">Best Tool of the World</a> html = "\n<div><a href=\"https://zammad.org\">Best Tool of the World</a>
some other text</div> some other text</div>
<div>" <div>"
result = "[1] Best Tool of the Worldsome other text\n\n[1] http://zammad.org" result = "[1] Best Tool of the Worldsome other text\n\n[1] https://zammad.org"
assert_equal(result, html.html2text) assert_equal(result, html.html2text)
html = "<!-- some comment --> html = "<!-- some comment -->
@ -397,9 +397,9 @@ P.S.: You receive this e-mail because you are listed in our database as person w
[1] http://www.teamviewer.example/en/company/unsubscribe.aspx?id=1009645&ident=xxx' [1] http://www.teamviewer.example/en/company/unsubscribe.aspx?id=1009645&ident=xxx'
assert_equal(result, html.html2text) assert_equal(result, html.html2text)
html = "<div><br>Dave and leaned her html = "<div><br>Dave and leaned her
days adam.</div><span style=\"color:#F7F3FF; font-size:8px\">Maybe we days adam.</div><span style=\"color:#F7F3FF; font-size:8px\">Maybe we
want any help me that.<br>Next morning charlie saw at their want any help me that.<br>Next morning charlie saw at their
father.<br>Well as though adam took out here. Melvin will be more money. father.<br>Well as though adam took out here. Melvin will be more money.
Called him into this one last thing.<br>Men----------------------- Called him into this one last thing.<br>Men-----------------------
<br />" <br />"

View file

@ -199,18 +199,64 @@ class ChatTest < ActiveSupport::TestCase
assert_equal(6, agent_state[:seads_total]) assert_equal(6, agent_state[:seads_total])
assert_equal(true, agent_state[:active]) assert_equal(true, agent_state[:active])
chat_session6.user_id = agent1.id
chat_session6.state = 'running' chat_session6.state = 'running'
chat_session6.save chat_session6.save
Chat::Message.create(
chat_session_id: chat_session6.id,
content: 'message 1',
created_by_id: agent1.id,
)
sleep 1
Chat::Message.create(
chat_session_id: chat_session6.id,
content: 'message 2',
created_by_id: agent1.id,
)
sleep 1
Chat::Message.create(
chat_session_id: chat_session6.id,
content: 'message 3',
created_by_id: agent1.id,
)
sleep 1
Chat::Message.create(
chat_session_id: chat_session6.id,
content: 'message 4',
created_by_id: nil,
)
# check customer state # check customer state
assert_equal('no_seats_available', chat.customer_state[:state]) customer_state = chat.customer_state
assert_equal(5, chat.customer_state[:queue]) assert_equal('no_seats_available', customer_state[:state])
assert_equal(5, customer_state[:queue])
# customer chat state
customer_state = chat.customer_state(chat_session6.session_id)
assert_equal('reconnect', customer_state[:state])
assert(customer_state[:session])
assert_equal(Array, customer_state[:session].class)
assert_equal('message 1', customer_state[:session][0]['content'])
assert_equal('message 2', customer_state[:session][1]['content'])
assert_equal('message 3', customer_state[:session][2]['content'])
assert_equal('message 4', customer_state[:session][3]['content'])
assert_equal('Notification Agent1', customer_state[:agent][:name])
assert_equal(nil, customer_state[:agent][:avatar])
# check agent1 state # check agent1 state
agent_state = Chat.agent_state_with_sessions(agent1.id) agent_state = Chat.agent_state_with_sessions(agent1.id)
assert_equal(5, agent_state[:waiting_chat_count]) assert_equal(5, agent_state[:waiting_chat_count])
assert_equal(1, agent_state[:running_chat_count]) assert_equal(1, agent_state[:running_chat_count])
assert_equal([], agent_state[:active_sessions]) assert_equal(Array, agent_state[:active_sessions].class)
assert_equal(chat.id, agent_state[:active_sessions][0]['chat_id'])
assert_equal(agent1.id, agent_state[:active_sessions][0]['user_id'])
assert(agent_state[:active_sessions][0]['messages'])
assert_equal(Array, agent_state[:active_sessions][0]['messages'].class)
assert_equal('message 1', agent_state[:active_sessions][0]['messages'][0]['content'])
assert_equal('message 2', agent_state[:active_sessions][0]['messages'][1]['content'])
assert_equal('message 3', agent_state[:active_sessions][0]['messages'][2]['content'])
assert_equal('message 4', agent_state[:active_sessions][0]['messages'][3]['content'])
assert_equal(0, agent_state[:seads_available]) assert_equal(0, agent_state[:seads_available])
assert_equal(6, agent_state[:seads_total]) assert_equal(6, agent_state[:seads_total])
assert_equal(true, agent_state[:active]) assert_equal(true, agent_state[:active])
@ -235,7 +281,15 @@ class ChatTest < ActiveSupport::TestCase
agent_state = Chat.agent_state_with_sessions(agent1.id) agent_state = Chat.agent_state_with_sessions(agent1.id)
assert_equal(5, agent_state[:waiting_chat_count]) assert_equal(5, agent_state[:waiting_chat_count])
assert_equal(1, agent_state[:running_chat_count]) assert_equal(1, agent_state[:running_chat_count])
assert_equal([], agent_state[:active_sessions]) assert_equal(Array, agent_state[:active_sessions].class)
assert_equal(chat.id, agent_state[:active_sessions][0]['chat_id'])
assert_equal(agent1.id, agent_state[:active_sessions][0]['user_id'])
assert(agent_state[:active_sessions][0]['messages'])
assert_equal(Array, agent_state[:active_sessions][0]['messages'].class)
assert_equal('message 1', agent_state[:active_sessions][0]['messages'][0]['content'])
assert_equal('message 2', agent_state[:active_sessions][0]['messages'][1]['content'])
assert_equal('message 3', agent_state[:active_sessions][0]['messages'][2]['content'])
assert_equal('message 4', agent_state[:active_sessions][0]['messages'][3]['content'])
assert_equal(-2, agent_state[:seads_available]) assert_equal(-2, agent_state[:seads_available])
assert_equal(4, agent_state[:seads_total]) assert_equal(4, agent_state[:seads_total])
assert_equal(true, agent_state[:active]) assert_equal(true, agent_state[:active])