From e59c35892723c6c8b469c1ba016d9e62d3fe12b2 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 10:31:35 +0100 Subject: Added :autofocus => true to :name --- app/views/tenants/_form_core.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/tenants/_form_core.html.haml b/app/views/tenants/_form_core.html.haml index 4eb2ccc..e0b173d 100644 --- a/app/views/tenants/_form_core.html.haml +++ b/app/views/tenants/_form_core.html.haml @@ -1,3 +1,3 @@ .inputs - = f.input :name, :label => t('tenants.form.name.label'), :hint => conditional_hint('tenants.form.name.hint') + = f.input :name, :label => t('tenants.form.name.label'), :hint => conditional_hint('tenants.form.name.hint'), :autofocus => true = f.input :description, :label => t('tenants.form.description.label'), :hint => conditional_hint('tenants.form.description.hint') -- cgit v1.2.3 From 544ea50a66da81989d0320735724bd09786be8ea Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 11:23:09 +0100 Subject: Fixed some logic bugs. --- Gemfile.lock | 2 +- app/assets/javascripts/phones.js.coffee | 2 -- app/controllers/phones_controller.rb | 7 +++++-- app/views/phones/_form_core.html.haml | 3 +++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e07b89e..f9a6596 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -84,7 +84,7 @@ GEM faye-websocket (0.4.1) eventmachine (>= 0.12.0) fssm (0.2.8.1) - haml (3.1.4) + haml (3.1.7) hike (1.2.1) hirb (0.6.1) http_accept_language (1.0.2) diff --git a/app/assets/javascripts/phones.js.coffee b/app/assets/javascripts/phones.js.coffee index ff54777..d917d09 100644 --- a/app/assets/javascripts/phones.js.coffee +++ b/app/assets/javascripts/phones.js.coffee @@ -1,5 +1,3 @@ jQuery -> - $(".fallback_sip_account_dropdown").hide() - $("#phone_hot_deskable").change -> $(".fallback_sip_account_dropdown").show("slow") diff --git a/app/controllers/phones_controller.rb b/app/controllers/phones_controller.rb index f1dcd3e..2698465 100644 --- a/app/controllers/phones_controller.rb +++ b/app/controllers/phones_controller.rb @@ -13,9 +13,9 @@ class PhonesController < ApplicationController end def new - set_fallback_sip_accounts - @phone = @phoneable.phones.build() + + set_fallback_sip_accounts # Use the last phone.phone_model as the default. # @@ -80,6 +80,9 @@ class PhonesController < ApplicationController def set_fallback_sip_accounts used_sip_account_ids = Phone.where(:fallback_sip_account_id => SipAccount.pluck(:id)).pluck(:fallback_sip_account_id) @fallback_sip_accounts = SipAccount.where(:sip_accountable_type => 'Tenant').where(:hotdeskable => true) - SipAccount.where(:id => used_sip_account_ids) + if @phone && !@phone.fallback_sip_account_id.blank? && SipAccount.exists?(@phone.fallback_sip_account_id) + @fallback_sip_accounts << SipAccount.where(:id => @phone.fallback_sip_account_id).first + end end end diff --git a/app/views/phones/_form_core.html.haml b/app/views/phones/_form_core.html.haml index fd69690..e0c664b 100644 --- a/app/views/phones/_form_core.html.haml +++ b/app/views/phones/_form_core.html.haml @@ -5,6 +5,9 @@ = f.input :hot_deskable, :label => t('phones.form.hot_deskable.label'), :hint => conditional_hint('phones.form.hot_deskable.hint') .fallback_sip_account_dropdown = f.association :fallback_sip_account, :collection => @fallback_sip_accounts, :label => t('phones.form.fallback_sip_account_id.label'), :hint => conditional_hint('phones.form.fallback_sip_account_id.hint'), :include_blank => false + - if !@phone.hot_deskable? + :javascript + $(".fallback_sip_account_dropdown").hide() - if defined? NIGHTLY_REBOOT_OF_PHONES && NIGHTLY_REBOOT_OF_PHONES == true = f.input :nightly_reboot, :label => t('phones.form.nightly_reboot.label'), :hint => conditional_hint('phones.form.nightly_reboot.hint') -- cgit v1.2.3 From e03b0b57f4c05210d198e2fab031cb4b7bdd5247 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 11:34:36 +0100 Subject: Added destroy_fallback_sip_account_if_not_hot_deskable --- app/models/phone.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/models/phone.rb b/app/models/phone.rb index 1f3c497..a606834 100644 --- a/app/models/phone.rb +++ b/app/models/phone.rb @@ -20,6 +20,7 @@ class Phone < ActiveRecord::Base # Validations # before_validation :sanitize_mac_address + before_validation :destroy_fallback_sip_account_if_not_hot_deskable validates_presence_of :mac_address validate_mac_address :mac_address @@ -227,5 +228,11 @@ class Phone < ActiveRecord::Base self.last_ip_address = nil end end + + def destroy_fallback_sip_account_if_not_hot_deskable + if !self.hot_deskable? + self.fallback_sip_account_id = nil + end + end end -- cgit v1.2.3 From e200751676f22dd9a83905eea0057beb57c9c9a7 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 11:57:15 +0100 Subject: Show a link to the phone's manual. --- app/views/phones/show.html.haml | 2 ++ config/locales/views/phones/de.yml | 1 + config/locales/views/phones/en.yml | 1 + 3 files changed, 4 insertions(+) diff --git a/app/views/phones/show.html.haml b/app/views/phones/show.html.haml index 090323e..268c469 100644 --- a/app/views/phones/show.html.haml +++ b/app/views/phones/show.html.haml @@ -6,6 +6,8 @@ %p %strong= t('phones.show.phone_model_id') + ":" = @phone.phone_model + - if !@phone.phone_model.product_manual_homepage_url.blank? + (#{link_to t('phones.show.manual'), @phone.phone_model.product_manual_homepage_url}) - if @phone.hot_deskable == true %p %strong= t('phones.show.hot_deskable') + ":" diff --git a/config/locales/views/phones/de.yml b/config/locales/views/phones/de.yml index dafe279..814267c 100644 --- a/config/locales/views/phones/de.yml +++ b/config/locales/views/phones/de.yml @@ -34,6 +34,7 @@ de: http_password: 'http password' nightly_reboot: 'Nachts automatischer Reboot' fallback_sip_account_id: 'Fallback SIP Account' + manual: 'Handbuch' actions: confirm: 'Sind Sie sicher, dass Sie diese Telefon aus Gemeinschaft entfernen möchten?' destroy: 'Löschen' diff --git a/config/locales/views/phones/en.yml b/config/locales/views/phones/en.yml index ecd5a91..15e212e 100644 --- a/config/locales/views/phones/en.yml +++ b/config/locales/views/phones/en.yml @@ -34,6 +34,7 @@ en: nightly_reboot: 'Nightly reboot' provisioning_key_active: 'Provisioning key active' fallback_sip_account_id: 'Fallback SIP Account' + manual: 'Manual' actions: confirm: 'Are you sure you want to delete this phone?' destroy: 'Delete phone' -- cgit v1.2.3 From 131d204324062991c93cd5418d1dc7854347ffb6 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 12:20:38 +0100 Subject: Added snom Meetingpoint (a conference phone). --- app/controllers/config_snom_controller.rb | 1 + db/migrate/20121230110747_snom_meetingpoint.rb | 14 ++++++++++++++ db/schema.rb | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20121230110747_snom_meetingpoint.rb diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb index 4d12082..7542415 100644 --- a/app/controllers/config_snom_controller.rb +++ b/app/controllers/config_snom_controller.rb @@ -80,6 +80,7 @@ class ConfigSnomController < ApplicationController '00041345' => 'Snom 821', '00041348' => 'Snom 821', '00041341' => 'Snom 870', + '00041332' => 'snom MeetingPoint', } @phone.phone_model = PhoneModel.where(:name => mac_address_to_model[@mac_address[0, 8]]).first diff --git a/db/migrate/20121230110747_snom_meetingpoint.rb b/db/migrate/20121230110747_snom_meetingpoint.rb new file mode 100644 index 0000000..1484777 --- /dev/null +++ b/db/migrate/20121230110747_snom_meetingpoint.rb @@ -0,0 +1,14 @@ +class SnomMeetingpoint < ActiveRecord::Migration + def up + if Manufacturer.where(:ieee_name => 'SNOM Technology AG').any? + snom = Manufacturer.where(:ieee_name => 'SNOM Technology AG').first + snom.phone_models.create(:name => 'snom MeetingPoint', + :product_homepage_url => 'http://www.snom.com/en/products/sip-conference-phone/snom-meetingpoint/', + :product_manual_homepage_url => 'http://wiki.snom.com/Snom_MeetingPoint/Documentation') + end + end + + def down + PhoneModels.where(:name => 'snom MeetingPoint').destroy_all + end +end diff --git a/db/schema.rb b/db/schema.rb index 804ff5f..12114dc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20121228101454) do +ActiveRecord::Schema.define(:version => 20121230110747) do create_table "access_authorizations", :force => true do |t| t.string "access_authorizationable_type" -- cgit v1.2.3 From caf624f11f7de44289b3c994fc72cc5e32ed799e Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 15:48:03 +0100 Subject: Fixed a broken from. --- app/controllers/user_groups_controller.rb | 2 +- app/views/user_groups/_form.html.haml | 2 +- app/views/user_groups/_form_core.html.haml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/user_groups_controller.rb b/app/controllers/user_groups_controller.rb index 158abaa..64e7136 100644 --- a/app/controllers/user_groups_controller.rb +++ b/app/controllers/user_groups_controller.rb @@ -19,7 +19,7 @@ class UserGroupsController < ApplicationController def create @user_group = @parent.user_groups.build(params[:user_group]) if @user_group.save - redirect_to @user_group, :notice => t('user_groups.controller.successfuly_created') + redirect_to [@parent, @user_group], :notice => t('user_groups.controller.successfuly_created') else render :new end diff --git a/app/views/user_groups/_form.html.haml b/app/views/user_groups/_form.html.haml index cbe3cc4..3263fdd 100644 --- a/app/views/user_groups/_form.html.haml +++ b/app/views/user_groups/_form.html.haml @@ -1,4 +1,4 @@ -= simple_form_for(@user_group) do |f| += simple_form_for([@parent, @user_group]) do |f| = f.error_notification = render "form_core", :f => f diff --git a/app/views/user_groups/_form_core.html.haml b/app/views/user_groups/_form_core.html.haml index a45ba6f..edb0dbc 100644 --- a/app/views/user_groups/_form_core.html.haml +++ b/app/views/user_groups/_form_core.html.haml @@ -1,3 +1,3 @@ .inputs - = f.input :name, :label => t('user_groups.form.name.label'), :hint => conditional_hint('user_groups.form.name.hint') + = f.input :name, :label => t('user_groups.form.name.label'), :hint => conditional_hint('user_groups.form.name.hint'), :autofocus => true = f.input :description, :label => t('user_groups.form.description.label'), :hint => conditional_hint('user_groups.form.description.hint') -- cgit v1.2.3 From 3867ea2c1b7b839c1a1afc2a1abaa12f9dba74dd Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 17:08:53 +0100 Subject: Fixed wrong redirect paths for update and destroy. --- app/controllers/user_groups_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/user_groups_controller.rb b/app/controllers/user_groups_controller.rb index 64e7136..ff3292c 100644 --- a/app/controllers/user_groups_controller.rb +++ b/app/controllers/user_groups_controller.rb @@ -30,7 +30,7 @@ class UserGroupsController < ApplicationController def update if @user_group.update_attributes(params[:user_group]) - redirect_to @user_group, :notice => t('user_groups.controller.successfuly_updated') + redirect_to [@parent, @user_group], :notice => t('user_groups.controller.successfuly_updated') else render :edit end @@ -38,7 +38,7 @@ class UserGroupsController < ApplicationController def destroy @user_group.destroy - redirect_to user_groups_url, :notice => t('user_groups.controller.successfuly_destroyed') + redirect_to method( :"#{@parent.class.name.underscore}_user_groups_path" ).(@parent), :notice => t('user_groups.controller.successfuly_destroyed') end private -- cgit v1.2.3 From ed8953f05638c43d9c1e62cf3d3ff7da158f4c20 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 19:47:15 +0100 Subject: Added a First Steps page. --- app/controllers/page_controller.rb | 1 + app/controllers/tenants_controller.rb | 21 ++++++++++++++---- app/helpers/application_helper.rb | 20 +++++++++++++++++ app/views/page/beginners_intro.de.html.haml | 33 +++++++++++++++++++++++++++++ app/views/page/beginners_intro.html.haml | 33 +++++++++++++++++++++++++++++ config/routes.rb | 1 + 6 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 app/views/page/beginners_intro.de.html.haml create mode 100644 app/views/page/beginners_intro.html.haml diff --git a/app/controllers/page_controller.rb b/app/controllers/page_controller.rb index 1f37449..4ea4d25 100644 --- a/app/controllers/page_controller.rb +++ b/app/controllers/page_controller.rb @@ -7,6 +7,7 @@ class PageController < ApplicationController def index;end def conference;end + def beginners_intro;end private def if_fresh_system_then_go_to_wizard diff --git a/app/controllers/tenants_controller.rb b/app/controllers/tenants_controller.rb index 724d179..7bb8ecd 100644 --- a/app/controllers/tenants_controller.rb +++ b/app/controllers/tenants_controller.rb @@ -58,14 +58,27 @@ class TenantsController < ApplicationController end if Delayed::Job.count > 0 - redirect_to @tenant, :notice => t('tenants.controller.successfuly_created_plus_delayed_jobs', + if SipAccount.any? || Phone.any? + redirect_to @tenant, :notice => t('tenants.controller.successfuly_created_plus_delayed_jobs', :resource => @tenant, :amount_of_numbers => @tenant.array_of_internal_extension_numbers.count + @tenant.array_of_dids.count ) - else - redirect_to @tenant, :notice => t('tenants.controller.successfuly_created', - :resource => @tenant + else + redirect_to page_beginners_intro_path, :notice => t('tenants.controller.successfuly_created_plus_delayed_jobs', + :resource => @tenant, + :amount_of_numbers => @tenant.array_of_internal_extension_numbers.count + @tenant.array_of_dids.count ) + end + else + if SipAccount.any? || Phone.any? + redirect_to @tenant, :notice => t('tenants.controller.successfuly_created', + :resource => @tenant + ) + else + redirect_to page_beginners_intro_path, :notice => t('tenants.controller.successfuly_created', + :resource => @tenant + ) + end end else render :new diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..de4d677 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,22 @@ module ApplicationHelper + + # nicely_joined_with_commata(['1', '2', '3', '4']) + # = '1, 2, 3 und 4' + # + def nicely_joined_with_commata(array_of_things) + if array_of_things.count == 1 + array_of_things.first.to_s + else + if array_of_things.count > 1 + output = array_of_things[0, array_of_things.count - 1].map{|item| item.to_s}.join(', ') + if I18n.locale == :de + output += ' und ' + else + output += ' and ' + end + output += array_of_things.last.to_s + end + end + end + end diff --git a/app/views/page/beginners_intro.de.html.haml b/app/views/page/beginners_intro.de.html.haml new file mode 100644 index 0000000..8d129db --- /dev/null +++ b/app/views/page/beginners_intro.de.html.haml @@ -0,0 +1,33 @@ +- title "Erste Schritte mit Gemeinschaft #{GEMEINSCHAFT_VERSION}!" + +%p + Sie müssen als erstes mindestens zwei neue SIP-Accounts anlegen. Dabei haben Sie die Wahl zwischen folgenden Varianten: + +%ul + %li + %strong + Personalisierter SIP-Accounts + %br + Dieser wird einer bestimmten Person zugeordnet. In einer normalen Gemeinschaft-Installation sind die meisten SIP-Accounts personalisiert. + %br + =link_to "SIP-Account für #{current_user} anlegen.", new_user_sip_account_path(current_user) + %li + %strong + Firmen SIP-Accounts + %br + Es gibt bestimmte SIP-Account, die keiner bestimmten Person zugeordnet werden können (z.B. für Telefone in einem Konferenzraum). Dafür gibt es Firmen SIP-Accounts. + %br + =link_to "SIP-Account für #{current_user.current_tenant} anlegen.", new_tenant_sip_account_path(current_user.current_tenant) + +%h2 Rufnummern + +%p + Mit denen von Ihnen angelegten SIP-Accounts können Sie schon intern telefonieren. Dazu müssen Sie den SIP-Accounts jeweils eine interne Telefonnummer zuweisen (z.B. 20 und 21) und ein SIP Soft- oder Hardphone mit den Account-Daten konfigurieren. + +%h2 Telefone + +%p + Komfortabler ist der Betrieb von im Provisioning unterstützen Telefone. Diese können Sie beim Anlegen direkt mit einem bestimmten SIP-Account verknüpfen. Danach müssen Sie nur noch die Provisioningdaten per Hand ins Telefon eintragen oder ein paar Einstellungen in Ihrem DHCP-Server vornehmen. Hilfe dazu finden Sie im #{link_to 'Wiki', 'https://github.com/amooma/GS5/wiki'} und der #{link_to 'Mailingliste', 'https://groups.google.com/group/gs5-users/'}. +%p + Folgende Telefone werden in der Version #{GEMEINSCHAFT_VERSION} vom automatischen Provisioning unterstützt: + = nicely_joined_with_commata(PhoneModel.order(:name).map{|phone_model| "#{phone_model.to_s}"}) \ No newline at end of file diff --git a/app/views/page/beginners_intro.html.haml b/app/views/page/beginners_intro.html.haml new file mode 100644 index 0000000..6227142 --- /dev/null +++ b/app/views/page/beginners_intro.html.haml @@ -0,0 +1,33 @@ +- title "First steps with Gemeinschaft #{GEMEINSCHAFT_VERSION}!" + +%p + You have to create at least two new SIP accounts. You have the choice of two different versions: + +%ul + %li + %strong + Personalized SIP accounts + %br + They are linked to a user. In a normal Gemeinschaft installation the majority of accounts are personlized. + %br + =link_to "Create a SIP account for #{current_user}.", new_user_sip_account_path(current_user) + %li + %strong + Company SIP accounts + %br + These are for phones which are not linked to a specific person (e.g. phones in conference rooms). + %br + =link_to "Create a SIP account for #{current_user.current_tenant}.", new_tenant_sip_account_path(current_user.current_tenant) + +%h2 Phone numbers + +%p + You can use your SIP accounts to make internal calls. But before that you have to add phone numbers to each SIP account (e.g. 20 and 21). After you did that you can configure any SIP phone with the SIP account configuration and start using your new PBX. + +%h2 Phones + +%p + More comfortable is the use of auto provisioned phones. They can be linked to SIP accounts. After creating them in the WebGUI you have to set the Provisioning URL in the phone or setup your DHCP server to give them this data. You'll find help in our #{link_to 'Wiki', 'https://github.com/amooma/GS5/wiki'} or in our #{link_to 'mailinglist', 'https://groups.google.com/group/gs5-users/'}. +%p + In version #{GEMEINSCHAFT_VERSION} the following phones can be used for provisioning: + = nicely_joined_with_commata(PhoneModel.order(:name).map{|phone_model| "#{phone_model.to_s}"}) \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 64d64cf..33238dc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -199,6 +199,7 @@ Gemeinschaft42c::Application.routes.draw do get "page/index" get "page/conference" + get "page/beginners_intro" root :to => "page#index" -- cgit v1.2.3 From 1c84298030ece53b5915ccca3460c04889abaffe Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 20:41:31 +0100 Subject: Added the provisioning URL for Snom phones in phone#view. --- app/views/phones/show.html.haml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/views/phones/show.html.haml b/app/views/phones/show.html.haml index 268c469..a7ee952 100644 --- a/app/views/phones/show.html.haml +++ b/app/views/phones/show.html.haml @@ -29,6 +29,12 @@ %strong= t('phones.show.ip_address') + ":" = @phone.ip_address +- if @phone.ip_address.blank? && @phone.phone_model.manufacturer.ieee_name == 'SNOM Technology AG' + %p + Sollten Sie Ihren DHCP-Server noch nicht für das automatische Konfigurieren der GS5 Provisionierungs-URL konfiguriert haben, können Sie manuell in Ihrem Telefon die folgende Provisionierungs-URL eingeben. Das "{mac}" bitte genau so eingeben, es wird vom Telefon automatisch mit der eigenen MAC-Adresse befüllt: + %pre + = "http://#{GemeinschaftSetup.first.sip_domain.host}/settings-{mac}" + = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @phone.phoneable, :child => @phone } %h2= t("phones.sip_accounts.title") -- cgit v1.2.3 From 31eb9759f88d259bba47b450baec7065ecad0f37 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 20:49:57 +0100 Subject: Added incoming phonebook number lookup. --- misc/freeswitch/scripts/ini/dialplan.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/misc/freeswitch/scripts/ini/dialplan.ini b/misc/freeswitch/scripts/ini/dialplan.ini index f4a6b66..aab8353 100644 --- a/misc/freeswitch/scripts/ini/dialplan.ini +++ b/misc/freeswitch/scripts/ini/dialplan.ini @@ -9,3 +9,6 @@ user_image_url = http://192.168.0.150/uploads/user/image ringtone_url = http://192.168.0.150 ringback = %(2000,4000,440.0,480.0) tone_busy = %(500,500,480,620);loops=4 + +phonebook_number_lookup = true +geo_number_lookup = true \ No newline at end of file -- cgit v1.2.3 From 57c4cd9834724d73c45425b0876aaed111ef3e1c Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 20:59:49 +0100 Subject: White space. --- db/migrate/20121230110747_snom_meetingpoint.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/migrate/20121230110747_snom_meetingpoint.rb b/db/migrate/20121230110747_snom_meetingpoint.rb index 1484777..04ad450 100644 --- a/db/migrate/20121230110747_snom_meetingpoint.rb +++ b/db/migrate/20121230110747_snom_meetingpoint.rb @@ -1,14 +1,14 @@ class SnomMeetingpoint < ActiveRecord::Migration def up - if Manufacturer.where(:ieee_name => 'SNOM Technology AG').any? - snom = Manufacturer.where(:ieee_name => 'SNOM Technology AG').first - snom.phone_models.create(:name => 'snom MeetingPoint', + if Manufacturer.where(:ieee_name => 'SNOM Technology AG').any? + snom = Manufacturer.where(:ieee_name => 'SNOM Technology AG').first + snom.phone_models.create(:name => 'snom MeetingPoint', :product_homepage_url => 'http://www.snom.com/en/products/sip-conference-phone/snom-meetingpoint/', :product_manual_homepage_url => 'http://wiki.snom.com/Snom_MeetingPoint/Documentation') - end + end end def down - PhoneModels.where(:name => 'snom MeetingPoint').destroy_all + PhoneModels.where(:name => 'snom MeetingPoint').destroy_all end end -- cgit v1.2.3 From 508871c01cbf02bf6d8d7056c2d5a70e4d67eebf Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 21:02:50 +0100 Subject: Version 5.0.2 --- config/initializers/gemeinschaft_parameters.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/gemeinschaft_parameters.rb b/config/initializers/gemeinschaft_parameters.rb index ffb8fee..b1481ef 100644 --- a/config/initializers/gemeinschaft_parameters.rb +++ b/config/initializers/gemeinschaft_parameters.rb @@ -1,6 +1,6 @@ # Use this file to set generic parameters for Gemeinschaft -GEMEINSCHAFT_VERSION = '5.0.1' +GEMEINSCHAFT_VERSION = '5.0.2' SUPER_TENANT_NAME = 'Super-Tenant' # System defaults -- cgit v1.2.3 From 7525ca487b993cc04c5540c0cf3bee4dabc2cc1c Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 21:04:13 +0100 Subject: Added nightly build to the release number. --- config/initializers/gemeinschaft_parameters.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/gemeinschaft_parameters.rb b/config/initializers/gemeinschaft_parameters.rb index b1481ef..1624165 100644 --- a/config/initializers/gemeinschaft_parameters.rb +++ b/config/initializers/gemeinschaft_parameters.rb @@ -1,6 +1,6 @@ # Use this file to set generic parameters for Gemeinschaft -GEMEINSCHAFT_VERSION = '5.0.2' +GEMEINSCHAFT_VERSION = '5.0.2-nightly-build' SUPER_TENANT_NAME = 'Super-Tenant' # System defaults -- cgit v1.2.3 From 2a165046b5e1bc32ccb5930be76be10c6d80d7fb Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 21:28:42 +0100 Subject: Updated some gems. --- Gemfile.lock | 113 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index f9a6596..696166f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,95 +28,95 @@ GEM activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) - acts_as_list (0.1.5) - addressable (2.2.7) + acts_as_list (0.1.9) + addressable (2.3.2) arel (3.0.2) bcrypt-ruby (3.0.1) - breadcrumbs_on_rails (2.2.0) - builder (3.0.0) - cancan (1.6.7) - carrierwave (0.5.8) - activesupport (~> 3.0) - chunky_png (1.2.5) + breadcrumbs_on_rails (2.3.0) + builder (3.0.4) + cancan (1.6.8) + carrierwave (0.7.1) + activemodel (>= 3.2.0) + activesupport (>= 3.2.0) + chunky_png (1.2.6) coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.2.0) - compass (0.12.rc.1) + coffee-script-source (1.4.0) + compass (0.12.2) chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.1) - compass-rails (1.0.0.rc.3) - compass (~> 0.12.rc.0) + compass-rails (1.0.3) + compass (>= 0.12.2, < 0.14) cookiejar (0.3.0) - delayed_job (3.0.1) + delayed_job (3.0.4) activesupport (~> 3.0) - delayed_job_active_record (0.3.2) - activerecord (> 2.1.0) - delayed_job (~> 3.0.0) - em-http-request (1.0.1) + delayed_job_active_record (0.3.3) + activerecord (>= 2.1.0, < 4) + delayed_job (~> 3.0) + em-http-request (1.0.3) addressable (>= 2.2.3) cookiejar em-socksify eventmachine (>= 1.0.0.beta.4) http_parser.rb (>= 0.5.3) - em-socksify (0.1.0) - eventmachine + em-socksify (0.2.1) + eventmachine (>= 1.0.0.beta.4) erubis (2.7.0) - eventmachine (1.0.0.beta.4) - execjs (1.3.0) + eventmachine (1.0.0) + execjs (1.4.0) multi_json (~> 1.0) - factory_girl (2.6.1) - activesupport (>= 2.3.9) - factory_girl_rails (1.7.0) - factory_girl (~> 2.6.0) + factory_girl (4.1.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.1.0) + factory_girl (~> 4.1.0) railties (>= 3.0.0) - faye (0.8.0) + faye (0.8.6) cookiejar (>= 0.3.0) em-http-request (>= 0.3.0) eventmachine (>= 0.12.0) faye-websocket (>= 0.4.0) rack (>= 1.0.0) yajl-ruby (>= 1.0.0) - faye-websocket (0.4.1) + faye-websocket (0.4.6) eventmachine (>= 0.12.0) - fssm (0.2.8.1) + fssm (0.2.9) haml (3.1.7) hike (1.2.1) - hirb (0.6.1) + hirb (0.7.0) http_accept_language (1.0.2) http_parser.rb (0.5.3) - i18n (0.6.0) - journey (1.0.3) - jquery-rails (2.0.1) - railties (>= 3.2.0, < 5.0) - thor (~> 0.14) - json (1.6.5) - libv8 (3.3.10.4) + i18n (0.6.1) + journey (1.0.4) + jquery-rails (2.1.4) + railties (>= 3.0, < 5.0) + thor (>= 0.14, < 2.0) + json (1.7.5) macaddr (1.6.1) systemu (~> 2.5.0) - mail (2.4.3) + mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) - mime-types (1.17.2) + mime-types (1.19) mini_magick (3.4) subexec (~> 0.2.1) - multi_json (1.1.0) + multi_json (1.5.0) mysql2 (0.3.11) - nokogiri (1.5.5) + nokogiri (1.5.6) polyglot (0.3.3) - private_pub (1.0.1) + private_pub (1.0.3) faye rack (1.4.1) rack-cache (1.2) rack (>= 0.4) rack-ssl (1.3.2) rack - rack-test (0.6.1) + rack-test (0.6.2) rack (>= 1.0) rails (3.2.2) actionmailer (= 3.2.2) @@ -137,38 +137,39 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (~> 0.14.6) - rake (0.9.2.2) + rake (10.0.3) rdoc (3.12) json (~> 1.4) + ref (1.0.2) ruby-graphviz (0.9.21) - sass (3.1.15) - sass-rails (3.2.4) + sass (3.2.4) + sass-rails (3.2.5) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) simple_form (2.0.1) actionpack (~> 3.0) activemodel (~> 3.0) - sprockets (2.1.2) + sprockets (2.1.3) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.5) + sqlite3 (1.3.6) state_machine (1.1.2) - subexec (0.2.1) - systemu (2.5.1) - therubyracer (0.9.10) - libv8 (~> 3.3.10) + subexec (0.2.2) + systemu (2.5.2) + therubyracer (0.11.0) + ref thor (0.14.6) tilt (1.3.3) - treetop (1.4.10) + treetop (1.4.12) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.32) - uglifier (1.2.3) + tzinfo (0.3.35) + uglifier (1.3.0) execjs (>= 0.3.0) - multi_json (>= 1.0.2) - uuid (2.3.5) + multi_json (~> 1.0, >= 1.0.2) + uuid (2.3.6) macaddr (~> 1.0) will_paginate (3.0.3) yajl-ruby (1.1.0) -- cgit v1.2.3 From 4e716cea253be9293b247fbe74d25fe288b7853f Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 22:03:10 +0100 Subject: Converted Factory to FactoryGirl. --- Gemfile.lock | 4 +- test/factories/area_codes.rb | 10 +++-- test/factories/call_forwards.rb | 28 +++++++------- test/factories/conference_invitees.rb | 12 +++--- test/factories/conferences.rb | 12 +++--- test/factories/countries.rb | 12 +++--- test/factories/gemeinschaft_setups.rb | 12 +++--- test/factories/languages.rb | 8 ++-- test/factories/manufacturers.rb | 8 ++-- test/factories/ouis.rb | 8 ++-- test/factories/phone_book_entries.rb | 10 +++-- test/factories/phone_books.rb | 8 ++-- test/factories/phone_models.rb | 8 ++-- test/factories/phone_number_ranges.rb | 8 ++-- test/factories/phone_numbers.rb | 10 +++-- test/factories/phones.rb | 22 ++++++----- test/factories/sip_accounts.rb | 26 +++++++------ test/factories/sip_domains.rb | 8 ++-- test/factories/tenant_memberships.rb | 8 ++-- test/factories/tenants.rb | 11 +++--- test/factories/user_group_memberships.rb | 22 ++++++----- test/factories/user_groups.rb | 8 ++-- test/factories/users.rb | 18 +++++---- test/functional/call_forwards_controller_test.rb | 12 +++--- .../conference_invitees_controller_test.rb | 2 +- test/functional/conferences_controller_test.rb | 2 +- .../gemeinschaft_setups_controller_test.rb | 4 +- test/functional/manufacturers_controller_test.rb | 8 ++-- test/functional/page_controller_test.rb | 8 ++-- .../phone_book_entries_controller_test.rb | 4 +- test/functional/phone_books_controller_test.rb | 10 ++--- test/functional/phone_models_controller_test.rb | 12 +++--- .../phone_number_ranges_controller_test.rb | 2 +- test/functional/phone_numbers_controller_test.rb | 8 ++-- test/functional/phones_controller_test.rb | 4 +- .../phones_sip_accounts_controller_test.rb | 2 +- test/functional/sip_accounts_controller_test.rb | 8 ++-- test/functional/sip_domains_controller_test.rb | 4 +- test/functional/tenants_controller_test.rb | 4 +- test/functional/user_groups_controller_test.rb | 4 +- test/functional/users_controller_test.rb | 6 +-- test/unit/area_code_test.rb | 2 +- test/unit/call_forward_test.rb | 2 +- test/unit/conference_invitee_test.rb | 4 +- test/unit/conference_test.rb | 16 ++++---- test/unit/country_test.rb | 2 +- test/unit/gemeinschaft_setup_test.rb | 2 +- test/unit/language_test.rb | 2 +- test/unit/manufacturer_test.rb | 6 +-- test/unit/oui_test.rb | 4 +- test/unit/phone_book_entry_test.rb | 22 +++++------ test/unit/phone_book_test.rb | 44 +++++++++++----------- test/unit/phone_model_test.rb | 2 +- test/unit/phone_number_range_test.rb | 2 +- test/unit/phone_number_test.rb | 20 +++++----- test/unit/phone_test.rb | 14 +++---- test/unit/sip_account_test.rb | 10 ++--- test/unit/sip_domain_test.rb | 2 +- test/unit/tenant_membership_test.rb | 4 +- test/unit/tenant_test.rb | 12 +++--- test/unit/user_group_membership_test.rb | 20 +++++----- test/unit/user_group_test.rb | 20 +++++----- test/unit/user_test.rb | 24 ++++++------ 63 files changed, 332 insertions(+), 289 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 696166f..9336fe9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -50,8 +50,8 @@ GEM chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.1) - compass-rails (1.0.3) - compass (>= 0.12.2, < 0.14) + compass-rails (1.0.0.rc.3) + compass (~> 0.12.rc.0) cookiejar (0.3.0) delayed_job (3.0.4) activesupport (~> 3.0) diff --git a/test/factories/area_codes.rb b/test/factories/area_codes.rb index 87b2271..3ed894d 100644 --- a/test/factories/area_codes.rb +++ b/test/factories/area_codes.rb @@ -1,7 +1,9 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :area_code do |f| - f.sequence(:name) { |n| "AreaCode #{n}" } - f.sequence(:area_code) { |n| "#{n}" } - f.association :country +FactoryGirl.define do + factory :area_code do + sequence(:name) { |n| "AreaCode #{n}" } + sequence(:area_code) { |n| "#{n}" } + association :country + end end \ No newline at end of file diff --git a/test/factories/call_forwards.rb b/test/factories/call_forwards.rb index d275e9d..bdb899e 100644 --- a/test/factories/call_forwards.rb +++ b/test/factories/call_forwards.rb @@ -1,16 +1,18 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :call_forward do |f| - f.association :phone_number - #OPTIMIZE Make sure that the phone_number's phone_numberable - # isn't a phone_book_entry but a sip_account. - #f.sequence( :call_forward_case_id ) { |n| CallForwardCase.where(:value => "always").first.id } - #f.association :call_forward_case - f.sequence( :call_forward_case_id ) { |n| 1 } - f.sequence( :destination ) { |n| "20#{n}" } - f.sequence( :to_voicemail ) { |n| false } - f.sequence( :timeout ) { |n| nil } - f.sequence( :source ) { |n| nil } - f.sequence( :depth ) { |n| 5 } - f.sequence( :active ) { |n| false } +FactoryGirl.define do + factory :call_forward do + association :phone_number + #OPTIMIZE Make sure that the phone_number's phone_numberable + # isn't a phone_book_entry but a sip_account. + #f.sequence( :call_forward_case_id ) { |n| CallForwardCase.where(:value => "always").first.id } + #f.association :call_forward_case + sequence( :call_forward_case_id ) { |n| 1 } + sequence( :destination ) { |n| "20#{n}" } + sequence( :to_voicemail ) { |n| false } + sequence( :timeout ) { |n| nil } + sequence( :source ) { |n| nil } + sequence( :depth ) { |n| 5 } + sequence( :active ) { |n| false } + end end diff --git a/test/factories/conference_invitees.rb b/test/factories/conference_invitees.rb index 4e1eb68..54fa53a 100644 --- a/test/factories/conference_invitees.rb +++ b/test/factories/conference_invitees.rb @@ -1,8 +1,10 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :conference_invitee do |f| - f.phone_number { Factory.build(:phone_number) } - f.association :conference - f.speaker true - f.moderator false +FactoryGirl.define do + factory :conference_invitee do + phone_number { FactoryGirl.build(:phone_number) } + association :conference + speaker true + moderator false + end end \ No newline at end of file diff --git a/test/factories/conferences.rb b/test/factories/conferences.rb index 3c49a7a..7a563b7 100644 --- a/test/factories/conferences.rb +++ b/test/factories/conferences.rb @@ -1,8 +1,10 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :conference do |f| - f.sequence(:name) { |n| "Conference room #{n}" } - f.open_for_anybody true - f.association :conferenceable, :factory => :tenant - f.max_members 10 +FactoryGirl.define do + factory :conference do + sequence(:name) { |n| "Conference room #{n}" } + open_for_anybody true + association :conferenceable, :factory => :tenant + max_members 10 + end end \ No newline at end of file diff --git a/test/factories/countries.rb b/test/factories/countries.rb index cc3fc88..99caab5 100644 --- a/test/factories/countries.rb +++ b/test/factories/countries.rb @@ -1,8 +1,10 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :country do |f| - f.sequence(:name) { |n| "Country #{n}" } - f.sequence(:country_code) { |n| "#{n}" } - f.sequence(:international_call_prefix) { |n| "#{n}" } - f.sequence(:trunk_prefix) { |n| "#{n}" } +FactoryGirl.define do + factory :country do + sequence(:name) { |n| "Country #{n}" } + sequence(:country_code) { |n| "#{n}" } + sequence(:international_call_prefix) { |n| "#{n}" } + sequence(:trunk_prefix) { |n| "#{n}" } + end end \ No newline at end of file diff --git a/test/factories/gemeinschaft_setups.rb b/test/factories/gemeinschaft_setups.rb index ed69bc3..a2c0f72 100644 --- a/test/factories/gemeinschaft_setups.rb +++ b/test/factories/gemeinschaft_setups.rb @@ -1,8 +1,10 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :gemeinschaft_setup do |f| - f.association :user - f.association :sip_domain - f.association :country - f.association :language +FactoryGirl.define do + factory :gemeinschaft_setup do + association :user + association :sip_domain + association :country + association :language + end end \ No newline at end of file diff --git a/test/factories/languages.rb b/test/factories/languages.rb index 29d2ece..a8ecace 100644 --- a/test/factories/languages.rb +++ b/test/factories/languages.rb @@ -1,6 +1,8 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :language do |f| - f.name 'Deutsch' - f.code 'de' +FactoryGirl.define do + factory :language do + name 'Deutsch' + code 'de' + end end \ No newline at end of file diff --git a/test/factories/manufacturers.rb b/test/factories/manufacturers.rb index f091dd2..e211fc6 100644 --- a/test/factories/manufacturers.rb +++ b/test/factories/manufacturers.rb @@ -1,6 +1,8 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :manufacturer do |f| - f.sequence(:name) { |n| "#{n}. manufacturer" } - f.sequence(:ieee_name) { |n| "#{n}. ieee" } +FactoryGirl.define do + factory :manufacturer do + sequence(:name) { |n| "#{n}. manufacturer" } + sequence(:ieee_name) { |n| "#{n}. ieee" } + end end \ No newline at end of file diff --git a/test/factories/ouis.rb b/test/factories/ouis.rb index 3a90fd4..f99f02b 100644 --- a/test/factories/ouis.rb +++ b/test/factories/ouis.rb @@ -1,6 +1,8 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :oui do |f| - f.association :manufacturer - f.sequence(:value) { |n| (n + 11184810).to_s(16).upcase } +FactoryGirl.define do + factory :oui do + association :manufacturer + sequence(:value) { |n| (n + 11184810).to_s(16).upcase } + end end \ No newline at end of file diff --git a/test/factories/phone_book_entries.rb b/test/factories/phone_book_entries.rb index 7427886..8e1b535 100644 --- a/test/factories/phone_book_entries.rb +++ b/test/factories/phone_book_entries.rb @@ -1,7 +1,9 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :phone_book_entry do |f| - f.sequence(:last_name) { |n| "Lastname #{n}" } - f.sequence(:is_male) { |n| true } - f.association :phone_book +FactoryGirl.define do + factory :phone_book_entry do + sequence(:last_name) { |n| "Lastname #{n}" } + sequence(:is_male) { |n| true } + association :phone_book + end end diff --git a/test/factories/phone_books.rb b/test/factories/phone_books.rb index 4aa8d07..80e2a06 100644 --- a/test/factories/phone_books.rb +++ b/test/factories/phone_books.rb @@ -1,6 +1,8 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :phone_book do |f| - f.sequence(:name) { |n| "Phone book #{n}" } - f.association :phone_bookable, :factory => :user +FactoryGirl.define do + factory :phone_book do + sequence(:name) { |n| "Phone book #{n}" } + association :phone_bookable, :factory => :user + end end diff --git a/test/factories/phone_models.rb b/test/factories/phone_models.rb index 8e6a50f..28b8802 100644 --- a/test/factories/phone_models.rb +++ b/test/factories/phone_models.rb @@ -1,6 +1,8 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :phone_model do |f| - f.sequence(:name) { |n| "Phone Model #{n}" } - f.association :manufacturer +FactoryGirl.define do + factory :phone_model do + sequence(:name) { |n| "Phone Model #{n}" } + association :manufacturer + end end diff --git a/test/factories/phone_number_ranges.rb b/test/factories/phone_number_ranges.rb index cb2f7ee..68d9a03 100644 --- a/test/factories/phone_number_ranges.rb +++ b/test/factories/phone_number_ranges.rb @@ -1,6 +1,8 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :phone_number_range do |f| - f.name INTERNAL_EXTENSIONS - f.association :phone_number_rangeable, :factory => :tenant +FactoryGirl.define do + factory :phone_number_range do + name INTERNAL_EXTENSIONS + association :phone_number_rangeable, :factory => :tenant + end end diff --git a/test/factories/phone_numbers.rb b/test/factories/phone_numbers.rb index 74b43cc..3b25938 100644 --- a/test/factories/phone_numbers.rb +++ b/test/factories/phone_numbers.rb @@ -1,7 +1,9 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :phone_number do |f| - f.sequence(:name) { |n| "Name #{n}" } - f.sequence(:number) { |n| "(0)30 227 #{n}" } - f.association :phone_numberable, :factory => :phone_book_entry +FactoryGirl.define do + factory :phone_number do + sequence(:name) { |n| "Name #{n}" } + sequence(:number) { |n| "(0)30 227 #{n}" } + association :phone_numberable, :factory => :phone_book_entry + end end \ No newline at end of file diff --git a/test/factories/phones.rb b/test/factories/phones.rb index 646d548..af0b37a 100644 --- a/test/factories/phones.rb +++ b/test/factories/phones.rb @@ -1,15 +1,17 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :phone do |f| - f.sequence(:mac_address) { |n| ('%06d' % n).to_s + ('%06d' % n).to_s } - f.association :phone_model - f.association :phoneable, :factory => :tenant +FactoryGirl.define do + factory :phone do |f| + f.sequence(:mac_address) { |n| ('%06d' % n).to_s + ('%06d' % n).to_s } + f.association :phone_model + f.association :phoneable, :factory => :tenant - # We have to make sure that the OUI is created as well. - f.after_build do |instance| - Factory.create(:oui, - :manufacturer => instance.phone_model.manufacturer, - :value => instance.mac_address.slice(0, 6) - ) + # We have to make sure that the OUI is created as well. + f.after_build do |instance| + FactoryGirl.create(:oui, + :manufacturer => instance.phone_model.manufacturer, + :value => instance.mac_address.slice(0, 6) + ) + end end end \ No newline at end of file diff --git a/test/factories/sip_accounts.rb b/test/factories/sip_accounts.rb index 2f91717..a21fa27 100644 --- a/test/factories/sip_accounts.rb +++ b/test/factories/sip_accounts.rb @@ -1,17 +1,19 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :sip_account do |f| - f.association :sip_accountable, :factory => :user - f.sequence(:auth_name) {|n| "auth_name#{n}" } - f.sequence(:caller_name) {|n| "Foo Account #{n}" } - f.sequence(:password) {|n| "12345678" } - - f.after_build do |sip_account| - if sip_account.tenant_id.blank? - tenant = sip_account.create_tenant(FactoryGirl.build(:tenant).attributes) - sip_domain = tenant.create_sip_domain(FactoryGirl.build(:sip_domain).attributes) - sip_account.tenant.tenant_memberships.create(:user_id => sip_account.sip_accountable.id) - sip_account.tenant_id = tenant.id +FactoryGirl.define do + factory :sip_account do |f| + f.association :sip_accountable, :factory => :user + f.sequence(:auth_name) {|n| "auth_name#{n}" } + f.sequence(:caller_name) {|n| "Foo Account #{n}" } + f.sequence(:password) {|n| "12345678" } + + f.after_build do |sip_account| + if sip_account.tenant_id.blank? + tenant = sip_account.create_tenant(FactoryGirl.build(:tenant).attributes) + sip_domain = tenant.create_sip_domain(FactoryGirl.build(:sip_domain).attributes) + sip_account.tenant.tenant_memberships.create(:user_id => sip_account.sip_accountable.id) + sip_account.tenant_id = tenant.id + end end end end diff --git a/test/factories/sip_domains.rb b/test/factories/sip_domains.rb index 347b6a6..442f270 100644 --- a/test/factories/sip_domains.rb +++ b/test/factories/sip_domains.rb @@ -1,6 +1,8 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :sip_domain do |f| - f.sequence(:host ) {|n| "host#{n}.localdomain" } - f.sequence(:realm ) {|n| "host#{n}.localdomain" } +FactoryGirl.define do + factory :sip_domain do + sequence(:host ) {|n| "host#{n}.localdomain" } + sequence(:realm ) {|n| "host#{n}.localdomain" } + end end diff --git a/test/factories/tenant_memberships.rb b/test/factories/tenant_memberships.rb index ee52367..38c4cb8 100644 --- a/test/factories/tenant_memberships.rb +++ b/test/factories/tenant_memberships.rb @@ -1,6 +1,8 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :tenant_membership do |f| - f.association :user - f.association :tenant +FactoryGirl.define do + factory :tenant_membership do + association :user + association :tenant + end end \ No newline at end of file diff --git a/test/factories/tenants.rb b/test/factories/tenants.rb index 9a62e93..fc85e88 100644 --- a/test/factories/tenants.rb +++ b/test/factories/tenants.rb @@ -1,8 +1,9 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :tenant do |f| - f.sequence(:name) { |n| "Tenant #{n}" } - f.association :country - f.association :language -# f.association :sip_domain +FactoryGirl.define do + factory :tenant do + sequence(:name) { |n| "Tenant #{n}" } + association :country + association :language + end end diff --git a/test/factories/user_group_memberships.rb b/test/factories/user_group_memberships.rb index 7904f2f..8dc74f0 100644 --- a/test/factories/user_group_memberships.rb +++ b/test/factories/user_group_memberships.rb @@ -1,14 +1,16 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :user_group_membership do |f| - f.association :user_group - f.association :user - - # Make sure that the User is a member of the Tenant. - f.after_build do |instance| - Factory.create(:tenant_membership, - :tenant_id => instance.user_group.tenant.id, - :user_id => instance.user.id - ) +FactoryGirl.define do + factory :user_group_membership do |f| + f.association :user_group + f.association :user + + # Make sure that the User is a member of the Tenant. + f.after_build do |instance| + FactoryGirl.create(:tenant_membership, + :tenant_id => instance.user_group.tenant.id, + :user_id => instance.user.id + ) + end end end \ No newline at end of file diff --git a/test/factories/user_groups.rb b/test/factories/user_groups.rb index 9a448ec..c777d95 100644 --- a/test/factories/user_groups.rb +++ b/test/factories/user_groups.rb @@ -1,6 +1,8 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :user_group do |f| - f.sequence(:name) { |n| "UserGroup #{n}" } - f.association :tenant +FactoryGirl.define do + factory :user_group do + sequence(:name) { |n| "UserGroup #{n}" } + association :tenant + end end \ No newline at end of file diff --git a/test/factories/users.rb b/test/factories/users.rb index 3d53141..a84b41d 100644 --- a/test/factories/users.rb +++ b/test/factories/users.rb @@ -1,11 +1,13 @@ # Read about factories at http://github.com/thoughtbot/factory_girl -Factory.define :user do |f| - f.sequence(:user_name) { |n| "User #{n}" } - f.sequence(:first_name) { |n| "John #{n}" } - f.sequence(:last_name) { |n| "Smith #{n}" } - f.sequence(:email) { |n| "john.smith#{n}@company.com" } - f.sequence(:password) { |n| "Testpassword#{n}" } - f.sequence(:password_confirmation) { |n| "Testpassword#{n}" } - f.association :language +FactoryGirl.define do + factory :user do + sequence(:user_name) { |n| "User #{n}" } + sequence(:first_name) { |n| "John #{n}" } + sequence(:last_name) { |n| "Smith #{n}" } + sequence(:email) { |n| "john.smith#{n}@company.com" } + sequence(:password) { |n| "Testpassword#{n}" } + sequence(:password_confirmation) { |n| "Testpassword#{n}" } + association :language + end end \ No newline at end of file diff --git a/test/functional/call_forwards_controller_test.rb b/test/functional/call_forwards_controller_test.rb index 0993623..da8e6c9 100644 --- a/test/functional/call_forwards_controller_test.rb +++ b/test/functional/call_forwards_controller_test.rb @@ -3,27 +3,27 @@ require 'test_helper' class CallForwardsControllerTest < ActionController::TestCase setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) - #@tenant = Factory.create(:tenant) + #@tenant = FactoryGirl.create(:tenant) #@tenant.tenant_memberships.create(:user_id => @user.id) #@user.update_attributes!(:current_tenant_id => @tenant.id) - @sip_account = Factory.create( + @sip_account = FactoryGirl.create( :sip_account, :sip_accountable => @user, ) @user.sip_accounts << @sip_account @sip_account = @user.sip_accounts.last - @phone_number = Factory.create( + @phone_number = FactoryGirl.create( :phone_number, :phone_numberable => @sip_account, ) @sip_account.phone_numbers << @phone_number @phone_number = @sip_account.phone_numbers.last - @call_forward = Factory.create( + @call_forward = FactoryGirl.create( :call_forward, :phone_number => @phone_number, ) @@ -50,7 +50,7 @@ class CallForwardsControllerTest < ActionController::TestCase # assert_difference('CallForward.count') do # post :create, # :phone_number_id => @phone_number.to_param, -# :call_forward => Factory.attributes_for( +# :call_forward => FactoryGirl.attributes_for( # :call_forward # ) # end diff --git a/test/functional/conference_invitees_controller_test.rb b/test/functional/conference_invitees_controller_test.rb index 72d2e2c..8ac5479 100644 --- a/test/functional/conference_invitees_controller_test.rb +++ b/test/functional/conference_invitees_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class ConferenceInviteesControllerTest < ActionController::TestCase setup do - @conference_invitee = Factory.create(:conference_invitee) + @conference_invitee = FactoryGirl.create(:conference_invitee) end # test "should get index" do diff --git a/test/functional/conferences_controller_test.rb b/test/functional/conferences_controller_test.rb index 954838b..0f2d007 100644 --- a/test/functional/conferences_controller_test.rb +++ b/test/functional/conferences_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class ConferencesControllerTest < ActionController::TestCase setup do - @conference = Factory.create(:conference) + @conference = FactoryGirl.create(:conference) end # test "should get index" do diff --git a/test/functional/gemeinschaft_setups_controller_test.rb b/test/functional/gemeinschaft_setups_controller_test.rb index b23a878..5e6cadf 100644 --- a/test/functional/gemeinschaft_setups_controller_test.rb +++ b/test/functional/gemeinschaft_setups_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class GemeinschaftSetupsControllerTest < ActionController::TestCase setup do - @gemeinschaft_setup = Factory.build(:gemeinschaft_setup) + @gemeinschaft_setup = FactoryGirl.build(:gemeinschaft_setup) end # test "should get index" do @@ -20,7 +20,7 @@ class GemeinschaftSetupsControllerTest < ActionController::TestCase # test "should create gemeinschaft_setup" do # assert_difference('GemeinschaftSetup.count') do # post :create, -# gemeinschaft_setup: Factory.attributes_for(:gemeinschaft_setup) +# gemeinschaft_setup: FactoryGirl.attributes_for(:gemeinschaft_setup) # end # assert_redirected_to gemeinschaft_setup_path(assigns(:gemeinschaft_setup)) # end diff --git a/test/functional/manufacturers_controller_test.rb b/test/functional/manufacturers_controller_test.rb index dad38e5..0b10f6d 100644 --- a/test/functional/manufacturers_controller_test.rb +++ b/test/functional/manufacturers_controller_test.rb @@ -2,14 +2,14 @@ require 'test_helper' class ManufacturersControllerTest < ActionController::TestCase setup do - @tenant = Factory.create(:tenant) - @user = Factory.create(:user) + @tenant = FactoryGirl.create(:tenant) + @user = FactoryGirl.create(:user) @tenant.tenant_memberships.create(:user_id => @user.id) @user.update_attributes!(:current_tenant_id => @tenant.id) - @manufacturer = Factory.create(:manufacturer) + @manufacturer = FactoryGirl.create(:manufacturer) @expected_status_if_not_authorized = :redirect end @@ -46,7 +46,7 @@ class ManufacturersControllerTest < ActionController::TestCase # # test "should create manufacturer" do # assert_difference('Manufacturer.count') do - # post :create, manufacturer: Factory.build(:manufacturer).attributes + # post :create, manufacturer: FactoryGirl.build(:manufacturer).attributes # end # # assert_redirected_to manufacturer_path(assigns(:manufacturer)) diff --git a/test/functional/page_controller_test.rb b/test/functional/page_controller_test.rb index a5ae5ad..2bc1b80 100644 --- a/test/functional/page_controller_test.rb +++ b/test/functional/page_controller_test.rb @@ -11,8 +11,8 @@ class PageControllerTest < ActionController::TestCase test "a logged in user should get index" do - @tenant = Factory.create(:tenant) - @user = Factory.create(:user) + @tenant = FactoryGirl.create(:tenant) + @user = FactoryGirl.create(:user) @tenant.users << @user @@ -22,8 +22,8 @@ class PageControllerTest < ActionController::TestCase end test "a logged out user should be redirected to the login" do - @tenant = Factory.create(:tenant) - @user = Factory.create(:user) + @tenant = FactoryGirl.create(:tenant) + @user = FactoryGirl.create(:user) @tenant.users << @user diff --git a/test/functional/phone_book_entries_controller_test.rb b/test/functional/phone_book_entries_controller_test.rb index 81c5b61..b340f0f 100644 --- a/test/functional/phone_book_entries_controller_test.rb +++ b/test/functional/phone_book_entries_controller_test.rb @@ -3,9 +3,9 @@ require 'test_helper' class PhoneBookEntriesControllerTest < ActionController::TestCase setup do - @user1 = Factory.create(:user) + @user1 = FactoryGirl.create(:user) pb = @user1.phone_books.first - @user1_phone_book_entry = Factory.create( + @user1_phone_book_entry = FactoryGirl.create( :phone_book_entry, :phone_book_id => pb.id ) diff --git a/test/functional/phone_books_controller_test.rb b/test/functional/phone_books_controller_test.rb index a00f597..aef2890 100644 --- a/test/functional/phone_books_controller_test.rb +++ b/test/functional/phone_books_controller_test.rb @@ -2,19 +2,19 @@ require 'test_helper' class PhoneBooksControllerTest < ActionController::TestCase setup do - @tenant = Factory.create(:tenant) + @tenant = FactoryGirl.create(:tenant) @admins = @tenant.user_groups.find_or_create_by_name('Admins') @users = @tenant.user_groups.find_or_create_by_name('Users') - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) @tenant.users << @user @users.users << @user - @personal_phone_book = Factory.create(:phone_book, + @personal_phone_book = FactoryGirl.create(:phone_book, :phone_bookable_type => @user.class.to_s, :phone_bookable_id => @user.id ) - phone_book_entry = Factory.create(:phone_book_entry) + phone_book_entry = FactoryGirl.create(:phone_book_entry) @personal_phone_book.phone_book_entries << phone_book_entry @expected_status_if_not_authorized = :redirect @@ -34,7 +34,7 @@ class PhoneBooksControllerTest < ActionController::TestCase end test "should create phone_book" do - phone_book2 = Factory.build(:phone_book, + phone_book2 = FactoryGirl.build(:phone_book, :phone_bookable_type => @user.class.to_s, :phone_bookable_id => @user.id ) diff --git a/test/functional/phone_models_controller_test.rb b/test/functional/phone_models_controller_test.rb index 2d1a87a..199be45 100644 --- a/test/functional/phone_models_controller_test.rb +++ b/test/functional/phone_models_controller_test.rb @@ -4,21 +4,21 @@ class PhoneModelsControllerTest < ActionController::TestCase setup do # Create a tenant: - @tenant = Factory.create(:tenant) + @tenant = FactoryGirl.create(:tenant) # Create a User who is member of the Tenant but has no special rights: - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) @tenant.tenant_memberships.create(:user_id => @user.id) @user.update_attributes!(:current_tenant_id => @tenant.id) # Create a User who is member of the Tenant and has super admin rights: - @super_admin = Factory.create(:user) + @super_admin = FactoryGirl.create(:user) @tenant.tenant_memberships.create(:user_id => @super_admin.id) @super_admin.update_attributes!(:current_tenant_id => @tenant.id) # Create a PhoneModel # - @phone_model = Factory.create(:phone_model) + @phone_model = FactoryGirl.create(:phone_model) end [ '@user.id', '' ].each do |user_id_code| @@ -44,7 +44,7 @@ class PhoneModelsControllerTest < ActionController::TestCase session[:user_id] = eval( user_id_code ) assert_no_difference('PhoneModel.count') do - post :create, manufacturer_id: @phone_model.manufacturer_id, phone_model: Factory.build(:phone_model, + post :create, manufacturer_id: @phone_model.manufacturer_id, phone_model: FactoryGirl.build(:phone_model, :manufacturer_id => @phone_model.manufacturer_id).attributes end end @@ -106,7 +106,7 @@ class PhoneModelsControllerTest < ActionController::TestCase # # add routes first. # test "should create phone_model as super admin" do # assert_difference('PhoneModel.count') do - # post :create, phone_model: Factory.build(:phone_model, + # post :create, phone_model: FactoryGirl.build(:phone_model, # :manufacturer_id => @phone_model.manufacturer_id).attributes # end # diff --git a/test/functional/phone_number_ranges_controller_test.rb b/test/functional/phone_number_ranges_controller_test.rb index 39f28c4..9569f3e 100644 --- a/test/functional/phone_number_ranges_controller_test.rb +++ b/test/functional/phone_number_ranges_controller_test.rb @@ -5,7 +5,7 @@ class PhoneNumberRangesControllerTest < ActionController::TestCase #TODO Uncomment tests once the views are implemented. setup do - @phone_number_range = Factory.create(:phone_number_range) + @phone_number_range = FactoryGirl.create(:phone_number_range) end test "should get index" do diff --git a/test/functional/phone_numbers_controller_test.rb b/test/functional/phone_numbers_controller_test.rb index ab0a4b2..b11e3e8 100644 --- a/test/functional/phone_numbers_controller_test.rb +++ b/test/functional/phone_numbers_controller_test.rb @@ -3,8 +3,8 @@ require 'test_helper' class PhoneNumbersControllerTest < ActionController::TestCase setup do - @tenant = Factory.create(:tenant) - @user = Factory.create(:user) + @tenant = FactoryGirl.create(:tenant) + @user = FactoryGirl.create(:user) @tenant.tenant_memberships.create(:user_id => @user.id) @@ -12,11 +12,11 @@ class PhoneNumbersControllerTest < ActionController::TestCase @private_phone_book = @user.phone_books.first - @private_phone_book_entry = Factory.create( + @private_phone_book_entry = FactoryGirl.create( :phone_book_entry, :phone_book => @private_phone_book ) - @phone_number = Factory.create( + @phone_number = FactoryGirl.create( :phone_number, :phone_numberable => @private_phone_book_entry ) diff --git a/test/functional/phones_controller_test.rb b/test/functional/phones_controller_test.rb index 1b0aa55..f2cc716 100644 --- a/test/functional/phones_controller_test.rb +++ b/test/functional/phones_controller_test.rb @@ -6,7 +6,7 @@ class PhonesControllerTest < ActionController::TestCase #TODO Uncomment tests once the route has been implemented. # setup do -# @phone = Factory.create(:phone) +# @phone = FactoryGirl.create(:phone) # end # # test "should get index" do @@ -24,7 +24,7 @@ class PhonesControllerTest < ActionController::TestCase # # # # test "should create phone" do # # assert_difference('Phone.count') do -# # post :create, phone: Factory.build(:phone, :phone_model_id => @phone.phone_model_id).attributes +# # post :create, phone: FactoryGirl.build(:phone, :phone_model_id => @phone.phone_model_id).attributes # # end # # # # assert_redirected_to phone_path(assigns(:phone)) diff --git a/test/functional/phones_sip_accounts_controller_test.rb b/test/functional/phones_sip_accounts_controller_test.rb index 967b8fe..834e502 100644 --- a/test/functional/phones_sip_accounts_controller_test.rb +++ b/test/functional/phones_sip_accounts_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PhonesSipAccountsControllerTest < ActionController::TestCase setup do - @phones_sip_account = Factory.create(:phones_sip_account) + @phones_sip_account = FactoryGirl.create(:phones_sip_account) end # test "should get index" do diff --git a/test/functional/sip_accounts_controller_test.rb b/test/functional/sip_accounts_controller_test.rb index 5c97dd2..e079718 100644 --- a/test/functional/sip_accounts_controller_test.rb +++ b/test/functional/sip_accounts_controller_test.rb @@ -3,10 +3,10 @@ require 'test_helper' class SipAccountsControllerTest < ActionController::TestCase setup do - @tenant = Factory.create(:tenant) - @user = Factory.create(:user) + @tenant = FactoryGirl.create(:tenant) + @user = FactoryGirl.create(:user) @tenant.tenant_memberships.create(:user_id => @user.id) - @sip_account = @user.sip_accounts.create( Factory.build(:sip_account).attributes ) + @sip_account = @user.sip_accounts.create( FactoryGirl.build(:sip_account).attributes ) @parent_param = @sip_account.sip_accountable_type.foreign_key.to_sym @parent_id = @sip_account.sip_accountable.id @@ -32,7 +32,7 @@ class SipAccountsControllerTest < ActionController::TestCase assert_difference('SipAccount.count') do post :create, @parent_param => @parent_id, - sip_account: Factory.attributes_for(:sip_account) + sip_account: FactoryGirl.attributes_for(:sip_account) end end diff --git a/test/functional/sip_domains_controller_test.rb b/test/functional/sip_domains_controller_test.rb index f26ea02..5cbd519 100644 --- a/test/functional/sip_domains_controller_test.rb +++ b/test/functional/sip_domains_controller_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class SipDomainsControllerTest < ActionController::TestCase setup do - @sip_domain = Factory.create(:sip_domain) + @sip_domain = FactoryGirl.create(:sip_domain) end test "should get index" do @@ -18,7 +18,7 @@ class SipDomainsControllerTest < ActionController::TestCase test "should create sip_domain" do assert_difference('SipDomain.count') do - post :create, sip_domain: Factory.build(:sip_domain).attributes + post :create, sip_domain: FactoryGirl.build(:sip_domain).attributes end assert_redirected_to sip_domain_path(assigns(:sip_domain)) diff --git a/test/functional/tenants_controller_test.rb b/test/functional/tenants_controller_test.rb index b4e2df4..7c5ec93 100644 --- a/test/functional/tenants_controller_test.rb +++ b/test/functional/tenants_controller_test.rb @@ -4,7 +4,7 @@ class TenantsControllerTest < ActionController::TestCase # TODO Create tests which test that a login user has specific rights. # setup do - # @tenant = Factory.create(:tenant) + # @tenant = FactoryGirl.create(:tenant) # end # # test "should get index" do @@ -20,7 +20,7 @@ class TenantsControllerTest < ActionController::TestCase # # test "should create tenant" do # assert_difference('Tenant.count') do - # post :create, tenant: Factory.build(:tenant).attributes + # post :create, tenant: FactoryGirl.build(:tenant).attributes # end # # assert_redirected_to tenant_path(assigns(:tenant)) diff --git a/test/functional/user_groups_controller_test.rb b/test/functional/user_groups_controller_test.rb index 0e39048..6f0c753 100644 --- a/test/functional/user_groups_controller_test.rb +++ b/test/functional/user_groups_controller_test.rb @@ -4,7 +4,7 @@ class UserGroupsControllerTest < ActionController::TestCase # TODO Create tests which test that a login user has specific rights. # setup do - # @user_group = Factory.create(:user_group) + # @user_group = FactoryGirl.create(:user_group) # end # # test "should get index" do @@ -20,7 +20,7 @@ class UserGroupsControllerTest < ActionController::TestCase # # test "should create user_group" do # assert_difference('UserGroup.count') do - # post :create, user_group: Factory.build(:user_group).attributes + # post :create, user_group: FactoryGirl.build(:user_group).attributes # end # # assert_redirected_to user_group_path(assigns(:user_group)) diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index d1898f7..987b3df 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -2,8 +2,8 @@ require 'test_helper' class UsersControllerTest < ActionController::TestCase setup do - @tenant = Factory.create(:tenant) - @user = Factory.create(:user) + @tenant = FactoryGirl.create(:tenant) + @user = FactoryGirl.create(:user) @tenant.tenant_memberships.create(:user_id => @user.id) @@ -30,7 +30,7 @@ class UsersControllerTest < ActionController::TestCase # test "should create user" do # session[:user_id] = nil # assert_difference('User.count') do - # post :create, user: Factory.build(:user).attributes + # post :create, user: FactoryGirl.build(:user).attributes # end # # # assert_redirected_to user_path(assigns(:user)) diff --git a/test/unit/area_code_test.rb b/test/unit/area_code_test.rb index 10c7c08..d59b290 100644 --- a/test/unit/area_code_test.rb +++ b/test/unit/area_code_test.rb @@ -2,6 +2,6 @@ require 'test_helper' class AreaCodeTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:area_code).valid? + assert FactoryGirl.build(:area_code).valid? end end diff --git a/test/unit/call_forward_test.rb b/test/unit/call_forward_test.rb index 95716c5..afde3c0 100644 --- a/test/unit/call_forward_test.rb +++ b/test/unit/call_forward_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class CallForwardTest < ActiveSupport::TestCase test "should have a valid factory" do - assert Factory.build(:call_forward).valid? + assert FactoryGirl.build(:call_forward).valid? end end diff --git a/test/unit/conference_invitee_test.rb b/test/unit/conference_invitee_test.rb index bcc4c9b..2823709 100644 --- a/test/unit/conference_invitee_test.rb +++ b/test/unit/conference_invitee_test.rb @@ -3,11 +3,11 @@ require 'test_helper' class ConferenceInviteeTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:conference_invitee).valid? + assert FactoryGirl.build(:conference_invitee).valid? end test "parent conference should not have a phone number twice" do - invitee = Factory.create(:conference_invitee) + invitee = FactoryGirl.create(:conference_invitee) conference = invitee.conference phone_number = PhoneNumber.new(:number => invitee.phone_number.number) invitee_bad = conference.conference_invitees.build(:phone_number => phone_number) diff --git a/test/unit/conference_test.rb b/test/unit/conference_test.rb index b7cce28..85f7ddb 100644 --- a/test/unit/conference_test.rb +++ b/test/unit/conference_test.rb @@ -3,29 +3,29 @@ require 'test_helper' class ConferenceTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:conference).valid? + assert FactoryGirl.build(:conference).valid? end def test_dates_must_make_sense # We can't create a conference in the past. - assert !Factory.build(:conference, :start => Time.now - 1.day, :end => Time.now + 1.day).valid? + assert !FactoryGirl.build(:conference, :start => Time.now - 1.day, :end => Time.now + 1.day).valid? # But we can create a conference which started 2 minutes ago. - assert Factory.build(:conference, :start => Time.now - 2.minutes, :end => Time.now + 1.hour).valid? + assert FactoryGirl.build(:conference, :start => Time.now - 2.minutes, :end => Time.now + 1.hour).valid? # The end must be before the start. - assert !Factory.build(:conference, :start => Time.now + 2.day, :end => Time.now + 1.day).valid? + assert !FactoryGirl.build(:conference, :start => Time.now + 2.day, :end => Time.now + 1.day).valid? # No date at all is fine. - assert Factory.build(:conference, :start => nil, :end => nil).valid? + assert FactoryGirl.build(:conference, :start => nil, :end => nil).valid? # Just start or just end is not ok. - assert !Factory.build(:conference, :start => nil, :end => Time.now + 1.day).valid? - assert !Factory.build(:conference, :start => Time.now + 1.day, :end => nil).valid? + assert !FactoryGirl.build(:conference, :start => nil, :end => Time.now + 1.day).valid? + assert !FactoryGirl.build(:conference, :start => Time.now + 1.day, :end => nil).valid? end def test_pin_must_be_nil_or_more_than_6_digits - conference = Factory.build(:conference, :pin => nil) + conference = FactoryGirl.build(:conference, :pin => nil) assert conference.valid? diff --git a/test/unit/country_test.rb b/test/unit/country_test.rb index 4933843..06f520e 100644 --- a/test/unit/country_test.rb +++ b/test/unit/country_test.rb @@ -2,6 +2,6 @@ require 'test_helper' class CountryTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:country).valid? + assert FactoryGirl.build(:country).valid? end end diff --git a/test/unit/gemeinschaft_setup_test.rb b/test/unit/gemeinschaft_setup_test.rb index 5ea6523..bd398ff 100644 --- a/test/unit/gemeinschaft_setup_test.rb +++ b/test/unit/gemeinschaft_setup_test.rb @@ -2,6 +2,6 @@ require 'test_helper' class GemeinschaftSetupTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:gemeinschaft_setup).valid? + assert FactoryGirl.build(:gemeinschaft_setup).valid? end end diff --git a/test/unit/language_test.rb b/test/unit/language_test.rb index 3308735..4a8cd77 100644 --- a/test/unit/language_test.rb +++ b/test/unit/language_test.rb @@ -2,6 +2,6 @@ require 'test_helper' class LanguageTest < ActiveSupport::TestCase test "has a valid factory" do - assert Factory.build(:language).valid? + assert FactoryGirl.build(:language).valid? end end diff --git a/test/unit/manufacturer_test.rb b/test/unit/manufacturer_test.rb index 635a977..012d34d 100644 --- a/test/unit/manufacturer_test.rb +++ b/test/unit/manufacturer_test.rb @@ -2,18 +2,18 @@ require 'test_helper' class ManufacturerTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:manufacturer).valid? + assert FactoryGirl.build(:manufacturer).valid? end # StateMachine Tests: def test_that_the_initial_state_should_be_active - @manufacturer = Factory.create(:manufacturer) + @manufacturer = FactoryGirl.create(:manufacturer) assert_equal 'active', @manufacturer.state assert @manufacturer.active? end def test_not_active_state_will_not_be_displayed - @manufacturer = Factory.create(:manufacturer) + @manufacturer = FactoryGirl.create(:manufacturer) assert_equal 1, Manufacturer.count @manufacturer.deactivate! diff --git a/test/unit/oui_test.rb b/test/unit/oui_test.rb index de48a97..cff5864 100644 --- a/test/unit/oui_test.rb +++ b/test/unit/oui_test.rb @@ -2,11 +2,11 @@ require 'test_helper' class OuiTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:oui).valid? + assert FactoryGirl.build(:oui).valid? end def test_that_the_initial_state_should_be_active - @oui = Factory.create(:oui) + @oui = FactoryGirl.create(:oui) assert_equal 'active', @oui.state assert @oui.active? end diff --git a/test/unit/phone_book_entry_test.rb b/test/unit/phone_book_entry_test.rb index c8d639b..2613398 100644 --- a/test/unit/phone_book_entry_test.rb +++ b/test/unit/phone_book_entry_test.rb @@ -2,17 +2,17 @@ require 'test_helper' class PhoneBookEntryTest < ActiveSupport::TestCase def test_should_be_valid - assert Factory.build(:phone_book_entry).valid? + assert FactoryGirl.build(:phone_book_entry).valid? end # TODO Fix this test. # test "only user can read entries in private phone books" do - # user = Factory.create(:user) - # phone_book = Factory.create(:phone_book, :phone_bookable_type => 'User', :phone_bookable_id => user.id) - # phone_book_entry = Factory.create(:phone_book_entry, :phone_book_id => phone_book.id) + # user = FactoryGirl.create(:user) + # phone_book = FactoryGirl.create(:phone_book, :phone_bookable_type => 'User', :phone_bookable_id => user.id) + # phone_book_entry = FactoryGirl.create(:phone_book_entry, :phone_book_id => phone_book.id) - # evil_user = Factory.create(:user) + # evil_user = FactoryGirl.create(:user) # user_ability = Ability.new( user ) # evil_user_ability = Ability.new( evil_user ) @@ -24,17 +24,17 @@ class PhoneBookEntryTest < ActiveSupport::TestCase # end def test_that_the_initial_state_should_be_active - @phone_book_entry = Factory.create(:phone_book_entry) + @phone_book_entry = FactoryGirl.create(:phone_book_entry) assert_equal 'active', @phone_book_entry.state assert @phone_book_entry.active? end test "a destroyed phone_book will destroy all phone_book_entries" do - phone_book = Factory.create(:phone_book) - 10.times { Factory.create(:phone_book_entry, :phone_book_id => phone_book.id) } + phone_book = FactoryGirl.create(:phone_book) + 10.times { FactoryGirl.create(:phone_book_entry, :phone_book_id => phone_book.id) } - phone_book2 = Factory.create(:phone_book) - 5.times { Factory.create(:phone_book_entry, :phone_book_id => phone_book2.id) } + phone_book2 = FactoryGirl.create(:phone_book) + 5.times { FactoryGirl.create(:phone_book_entry, :phone_book_id => phone_book2.id) } assert_equal 15, PhoneBookEntry.all.count @@ -44,7 +44,7 @@ class PhoneBookEntryTest < ActiveSupport::TestCase end test "that the value_of_to_s field is filled" do - phone_book_entry = Factory.create(:phone_book_entry) + phone_book_entry = FactoryGirl.create(:phone_book_entry) assert_equal phone_book_entry.value_of_to_s, phone_book_entry.to_s end diff --git a/test/unit/phone_book_test.rb b/test/unit/phone_book_test.rb index 7db48f8..b820521 100644 --- a/test/unit/phone_book_test.rb +++ b/test/unit/phone_book_test.rb @@ -2,15 +2,15 @@ require 'test_helper' class PhoneBookTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:phone_book).valid? + assert FactoryGirl.build(:phone_book).valid? end def test_should_have_unique_name_depending_on_type - user1 = Factory.create(:user) - user2 = Factory.create(:user) - tenant = Factory.create(:tenant) + user1 = FactoryGirl.create(:user) + user2 = FactoryGirl.create(:user) + tenant = FactoryGirl.create(:tenant) - phonebook = Factory.create(:phone_book, :phone_bookable => user1) + phonebook = FactoryGirl.create(:phone_book, :phone_bookable => user1) assert !user1.phone_books.build(:name => phonebook.name).valid? assert user2.phone_books.build(:name => phonebook.name).valid? assert tenant.phone_books.build(:name => phonebook.name).valid? @@ -20,7 +20,7 @@ class PhoneBookTest < ActiveSupport::TestCase # test "User gets a private phone book with rw rights" do - # user = Factory.create(:user) + # user = FactoryGirl.create(:user) # assert_equal 1, user.phone_books.count # phone_book = user.phone_books.first @@ -34,9 +34,9 @@ class PhoneBookTest < ActiveSupport::TestCase # # Lets test some stuff about the phone_book_entries # assert_equal 0, phone_book.phone_book_entries.count - # entry1 = Factory.create(:phone_book_entry, :phone_book_id => phone_book.id) - # entry2 = Factory.create(:phone_book_entry, :phone_book_id => phone_book.id) - # entry3 = Factory.create(:phone_book_entry, :phone_book_id => phone_book.id) + # entry1 = FactoryGirl.create(:phone_book_entry, :phone_book_id => phone_book.id) + # entry2 = FactoryGirl.create(:phone_book_entry, :phone_book_id => phone_book.id) + # entry3 = FactoryGirl.create(:phone_book_entry, :phone_book_id => phone_book.id) # assert_equal 3, phone_book.phone_book_entries.count # assert_equal 1, PhoneBookEntry.where(:id => entry1.id).count @@ -50,22 +50,22 @@ class PhoneBookTest < ActiveSupport::TestCase # end test "Tenant gets automatically one phone book and can destroy it" do - tenant = Factory.create(:tenant) + tenant = FactoryGirl.create(:tenant) assert_equal 1, tenant.phone_books.count tenant.phone_books.first.destroy assert_equal 0, tenant.phone_books.count end # test "only tenant members can read a tenant phone book" do - # tenant = Factory.create(:tenant) - # user = Factory.create(:user) + # tenant = FactoryGirl.create(:tenant) + # user = FactoryGirl.create(:user) # tenant.users << user # tenant.save # user.current_tenant = tenant # user.save - # phone_book = Factory.create(:phone_book, :phone_bookable_type => 'Tenant', :phone_bookable_id => tenant.id) + # phone_book = FactoryGirl.create(:phone_book, :phone_bookable_type => 'Tenant', :phone_bookable_id => tenant.id) - # evil_user = Factory.create(:user) + # evil_user = FactoryGirl.create(:user) # user_ability = Ability.new( user ) # evil_user_ability = Ability.new( evil_user ) @@ -79,12 +79,12 @@ class PhoneBookTest < ActiveSupport::TestCase # test "tenant's phone book can not be edited by tenant members" do - # tenant = Factory.create(:tenant) - # user = Factory.create(:user) + # tenant = FactoryGirl.create(:tenant) + # user = FactoryGirl.create(:user) # tenant.users << user - # phone_book = Factory.create(:phone_book, :phone_bookable_type => 'Tenant', :phone_bookable_id => tenant.id) + # phone_book = FactoryGirl.create(:phone_book, :phone_bookable_type => 'Tenant', :phone_bookable_id => tenant.id) - # evil_user = Factory.create(:user) + # evil_user = FactoryGirl.create(:user) # user_ability = Ability.new( user ) # evil_user_ability = Ability.new( evil_user ) @@ -96,10 +96,10 @@ class PhoneBookTest < ActiveSupport::TestCase # end # test "only user can manage his private phone book after creating it" do - # user = Factory.create(:user) - # phone_book = Factory.create(:phone_book, :phone_bookable_type => 'User', :phone_bookable_id => user.id) + # user = FactoryGirl.create(:user) + # phone_book = FactoryGirl.create(:phone_book, :phone_bookable_type => 'User', :phone_bookable_id => user.id) - # evil_user = Factory.create(:user) + # evil_user = FactoryGirl.create(:user) # user_ability = Ability.new( user ) # evil_user_ability = Ability.new( evil_user ) @@ -111,7 +111,7 @@ class PhoneBookTest < ActiveSupport::TestCase # end def test_that_the_initial_state_should_be_active - @phone_book = Factory.create(:phone_book) + @phone_book = FactoryGirl.create(:phone_book) assert_equal 'active', @phone_book.state assert @phone_book.active? end diff --git a/test/unit/phone_model_test.rb b/test/unit/phone_model_test.rb index e358cf9..ef293f4 100644 --- a/test/unit/phone_model_test.rb +++ b/test/unit/phone_model_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PhoneModelTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:phone_model).valid? + assert FactoryGirl.build(:phone_model).valid? end end diff --git a/test/unit/phone_number_range_test.rb b/test/unit/phone_number_range_test.rb index 1770299..e70cd60 100644 --- a/test/unit/phone_number_range_test.rb +++ b/test/unit/phone_number_range_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PhoneNumberRangeTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:phone_number_range).valid? + assert FactoryGirl.build(:phone_number_range).valid? end end diff --git a/test/unit/phone_number_test.rb b/test/unit/phone_number_test.rb index e10b20c..3fd92d6 100644 --- a/test/unit/phone_number_test.rb +++ b/test/unit/phone_number_test.rb @@ -5,17 +5,17 @@ require 'test_helper' class PhoneNumberTest < ActiveSupport::TestCase test "should have valid factory" do - assert Factory.build(:phone_number).valid? + assert FactoryGirl.build(:phone_number).valid? end def test_that_the_initial_state_should_be_active - @phone_number = Factory.create(:phone_number) + @phone_number = FactoryGirl.create(:phone_number) assert_equal 'active', @phone_number.state assert @phone_number.active? end test "that the value_of_to_s field is filled" do - phone_number = Factory.create(:phone_number) + phone_number = FactoryGirl.create(:phone_number) assert_equal phone_number.value_of_to_s, phone_number.to_s end @@ -198,7 +198,7 @@ class PhoneNumberTest < ActiveSupport::TestCase AreaCode.create(:country => germany, :name => "Hohenmocker", :area_code => "39993") # create a tenant - tenant = Factory.create(:tenant, :country_id => germany.id) + tenant = FactoryGirl.create(:tenant, :country_id => germany.id) # create some extensions internal_extension_range = tenant.phone_number_ranges.create(:name => INTERNAL_EXTENSIONS) ['2000', '2001', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '5', '99'].each do |extension| @@ -216,7 +216,7 @@ class PhoneNumberTest < ActiveSupport::TestCase # Language.create(:name => 'Deutsch', :code => 'de') # AreaCode.create(:country => germany, :name => "Bendorf", :area_code => "2622") - # @sip_domain = Factory.create(:sip_domain) + # @sip_domain = FactoryGirl.create(:sip_domain) # @tenant = @sip_domain.tenants.build(:name => 'AMOOMA GmbH') # @tenant.country = Country.first @@ -226,8 +226,8 @@ class PhoneNumberTest < ActiveSupport::TestCase # @tenant.generate_internal_extensions - # sip_account = @tenant.sip_accounts.build(Factory.create(:sip_account).attributes) - # phone_number = sip_account.phone_numbers.create(Factory.build(:phone_number, :number => '10').attributes) + # sip_account = @tenant.sip_accounts.build(FactoryGirl.create(:sip_account).attributes) + # phone_number = sip_account.phone_numbers.create(FactoryGirl.build(:phone_number, :number => '10').attributes) # phone_number_evil = sip_account.phone_numbers.build(phone_number.attributes) # assert phone_number.valid? @@ -235,14 +235,14 @@ class PhoneNumberTest < ActiveSupport::TestCase # end # test "has to be unique per SIP domain even for different tenants" do - # provider_sip_domain = Factory.create(:sip_domain) + # provider_sip_domain = FactoryGirl.create(:sip_domain) # tenants = [] # sip_accounts = [] # 2.times { |i| - # tenants[i] = provider_sip_domain.tenants.create(Factory.build(:tenant, :internal_extension_ranges => '10-20').attributes) + # tenants[i] = provider_sip_domain.tenants.create(FactoryGirl.build(:tenant, :internal_extension_ranges => '10-20').attributes) # tenants[i].generate_internal_extensions - # sip_accounts[i] = tenants[i].sip_accounts.build(Factory.build(:sip_account, :tenant_id => tenants[i].id).attributes) + # sip_accounts[i] = tenants[i].sip_accounts.build(FactoryGirl.build(:sip_account, :tenant_id => tenants[i].id).attributes) # sip_accounts[i].phone_numbers.build(:number => '10') # } # sip_accounts[0].save diff --git a/test/unit/phone_test.rb b/test/unit/phone_test.rb index 4ad21df..b9d33af 100644 --- a/test/unit/phone_test.rb +++ b/test/unit/phone_test.rb @@ -3,19 +3,19 @@ require 'test_helper' class PhoneTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:phone).valid? + assert FactoryGirl.build(:phone).valid? end # test "should destroy_all phones_sip_accounts if the phoneable changed" do - # sip_domain = Factory.create(:sip_domain) - # tenant = sip_domain.tenants.create(Factory.build(:tenant).attributes) + # sip_domain = FactoryGirl.create(:sip_domain) + # tenant = sip_domain.tenants.create(FactoryGirl.build(:tenant).attributes) # - # user1 = Factory.create(:user) - # user2 = Factory.create(:user) + # user1 = FactoryGirl.create(:user) + # user2 = FactoryGirl.create(:user) # tenant.tenant_memberships.create(:user_id => user1.id) # tenant.tenant_memberships.create(:user_id => user2.id) # - # phone = Factory.create(:phone, :phoneable => tenant) + # phone = FactoryGirl.create(:phone, :phoneable => tenant) # # # Nothing there # # @@ -28,7 +28,7 @@ class PhoneTest < ActiveSupport::TestCase # # # create some sip_accounts associated to phone # # - # 3.times { Factory.create(:sip_account, :sip_accountable => user1, :tenant_id => tenant.id) } + # 3.times { FactoryGirl.create(:sip_account, :sip_accountable => user1, :tenant_id => tenant.id) } # SipAccount.all.each do |sip_account| # phone.phones_sip_accounts.create(:sip_account_id => sip_account.id) # end diff --git a/test/unit/sip_account_test.rb b/test/unit/sip_account_test.rb index 6595ccc..e85e493 100644 --- a/test/unit/sip_account_test.rb +++ b/test/unit/sip_account_test.rb @@ -3,21 +3,21 @@ require 'test_helper' class SipAccountTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:sip_account).valid? + assert FactoryGirl.build(:sip_account).valid? end test "that the value_of_to_s field is filled" do - sip_account = Factory.create(:sip_account) + sip_account = FactoryGirl.create(:sip_account) assert_equal sip_account.value_of_to_s, sip_account.to_s end test "should have a unique auth_name per sip_domain" do - provider_sip_domain = Factory.create(:sip_domain) + provider_sip_domain = FactoryGirl.create(:sip_domain) tenants = [] sip_accounts = [] 2.times { |i| - tenants[i] = provider_sip_domain.tenants.create(Factory.build(:tenant).attributes) - sip_accounts[i] = Factory.build( + tenants[i] = provider_sip_domain.tenants.create(FactoryGirl.build(:tenant).attributes) + sip_accounts[i] = FactoryGirl.build( :sip_account, :sip_accountable => tenants[i], :auth_name => "somerandomauthname", diff --git a/test/unit/sip_domain_test.rb b/test/unit/sip_domain_test.rb index 5d31f69..61ac89a 100644 --- a/test/unit/sip_domain_test.rb +++ b/test/unit/sip_domain_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class SipDomainTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:sip_domain).valid? + assert FactoryGirl.build(:sip_domain).valid? end end diff --git a/test/unit/tenant_membership_test.rb b/test/unit/tenant_membership_test.rb index 8e7a191..ba57eae 100644 --- a/test/unit/tenant_membership_test.rb +++ b/test/unit/tenant_membership_test.rb @@ -2,11 +2,11 @@ require 'test_helper' class TenantMembershipTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:tenant_membership).valid? + assert FactoryGirl.build(:tenant_membership).valid? end def test_that_the_initial_state_should_be_active - @tenant_membership = Factory.create(:tenant_membership) + @tenant_membership = FactoryGirl.create(:tenant_membership) assert_equal 'active', @tenant_membership.state assert @tenant_membership.active? end diff --git a/test/unit/tenant_test.rb b/test/unit/tenant_test.rb index 4d4abce..0b342ba 100644 --- a/test/unit/tenant_test.rb +++ b/test/unit/tenant_test.rb @@ -2,23 +2,23 @@ require 'test_helper' class TenantTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:tenant).valid? + assert FactoryGirl.build(:tenant).valid? end def test_should_have_unique_name - tenant = Factory.create(:tenant) - assert !Factory.build(:tenant, :name => tenant.name).valid? - assert Factory.build(:tenant, :name => "different_#{tenant.name}").valid? + tenant = FactoryGirl.create(:tenant) + assert !FactoryGirl.build(:tenant, :name => tenant.name).valid? + assert FactoryGirl.build(:tenant, :name => "different_#{tenant.name}").valid? end def test_that_the_initial_state_should_be_active - @tenant = Factory.create(:tenant) + @tenant = FactoryGirl.create(:tenant) assert_equal 'active', @tenant.state assert @tenant.active? end def test_not_active_state_will_not_be_displayed - @tenant = Factory.create(:tenant) + @tenant = FactoryGirl.create(:tenant) assert_equal 1, Tenant.count @tenant.deactivate! diff --git a/test/unit/user_group_membership_test.rb b/test/unit/user_group_membership_test.rb index 251229f..34a577c 100644 --- a/test/unit/user_group_membership_test.rb +++ b/test/unit/user_group_membership_test.rb @@ -2,29 +2,29 @@ require 'test_helper' class UserGroupMembershipTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:user_group_membership).valid? + assert FactoryGirl.build(:user_group_membership).valid? end def test_should_have_unique_members_in_each_group - group1 = Factory.create(:user_group) - group2 = Factory.create(:user_group) - user1 = Factory.create(:user) - user2 = Factory.create(:user) - member = Factory.create( + group1 = FactoryGirl.create(:user_group) + group2 = FactoryGirl.create(:user_group) + user1 = FactoryGirl.create(:user) + user2 = FactoryGirl.create(:user) + member = FactoryGirl.create( :user_group_membership, :user_id => user1.id, :user_group_id => group1.id ) - assert !Factory.build( + assert !FactoryGirl.build( :user_group_membership, :user_id => user1.id, :user_group_id => group1.id ).valid? - assert Factory.build( + assert FactoryGirl.build( :user_group_membership, :user_id => user1.id, :user_group_id => group2.id ).valid? - assert Factory.build( + assert FactoryGirl.build( :user_group_membership, :user_id => user2.id, :user_group_id => group1.id @@ -32,7 +32,7 @@ class UserGroupMembershipTest < ActiveSupport::TestCase end def test_that_the_initial_state_should_be_active - @user_group_membership = Factory.create(:user_group_membership) + @user_group_membership = FactoryGirl.create(:user_group_membership) assert_equal 'active', @user_group_membership.state assert @user_group_membership.active? end diff --git a/test/unit/user_group_test.rb b/test/unit/user_group_test.rb index 5e815a8..1023bd6 100644 --- a/test/unit/user_group_test.rb +++ b/test/unit/user_group_test.rb @@ -2,23 +2,23 @@ require 'test_helper' class UserGroupTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:user_group).valid? + assert FactoryGirl.build(:user_group).valid? end def test_should_have_unique_name_on_same_tenant - tenant1 = Factory.create(:tenant) - tenant2 = Factory.create(:tenant) - group = Factory.create(:user_group, :tenant_id => tenant1.id) - assert !Factory.build(:user_group, :name => group.name, :tenant_id => tenant1.id).valid? - assert Factory.build(:user_group, :name => group.name, :tenant_id => tenant2.id).valid? - assert Factory.build(:user_group, :name => "different_#{group.name}", :tenant_id => tenant1.id).valid? + tenant1 = FactoryGirl.create(:tenant) + tenant2 = FactoryGirl.create(:tenant) + group = FactoryGirl.create(:user_group, :tenant_id => tenant1.id) + assert !FactoryGirl.build(:user_group, :name => group.name, :tenant_id => tenant1.id).valid? + assert FactoryGirl.build(:user_group, :name => group.name, :tenant_id => tenant2.id).valid? + assert FactoryGirl.build(:user_group, :name => "different_#{group.name}", :tenant_id => tenant1.id).valid? end test "user_group_membership only available for tenant_memberships" do - good_tenant = Factory.create(:tenant) - evil_tenant = Factory.create(:tenant) + good_tenant = FactoryGirl.create(:tenant) + evil_tenant = FactoryGirl.create(:tenant) - user = Factory.create(:user) + user = FactoryGirl.create(:user) good_tenant.tenant_memberships.create(:user_id => user.id) good_user_group = good_tenant.user_groups.create(:name => 'Example') diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index bb89e77..5fa1e4a 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -3,21 +3,21 @@ require 'test_helper' class UserTest < ActiveSupport::TestCase def test_should_have_a_valid_factory - assert Factory.build(:user).valid? + assert FactoryGirl.build(:user).valid? end def test_should_have_a_unique_email_address - user = Factory.create(:user) - assert !Factory.build(:user, :email => user.email).valid? - assert Factory.build(:user, :email => "different_#{user.email}").valid? + user = FactoryGirl.create(:user) + assert !FactoryGirl.build(:user, :email => user.email).valid? + assert FactoryGirl.build(:user, :email => "different_#{user.email}").valid? end def test_can_not_move_to_a_current_tenant_without_a_membership_relation - super_tenant = Factory.create(:tenant) - good_tenant = Factory.create(:tenant) - evil_tenant = Factory.create(:tenant) + super_tenant = FactoryGirl.create(:tenant) + good_tenant = FactoryGirl.create(:tenant) + evil_tenant = FactoryGirl.create(:tenant) - user = Factory.create(:user) + user = FactoryGirl.create(:user) super_tenant.tenant_memberships.create(:user_id => user.id) good_tenant.tenant_memberships.create(:user_id => user.id) @@ -27,7 +27,7 @@ class UserTest < ActiveSupport::TestCase end test "should be possible to modify the user without changing the PIN" do - user = Factory.create(:user) + user = FactoryGirl.create(:user) pin_salt = user.pin_salt pin_hash = user.pin_hash user.middle_name = "#{user.middle_name} Foo" @@ -39,7 +39,7 @@ class UserTest < ActiveSupport::TestCase end test "should be possible to change the PIN" do - user = Factory.create(:user) + user = FactoryGirl.create(:user) pin_salt = user.pin_salt pin_hash = user.pin_hash new_pin = '453267' @@ -52,7 +52,7 @@ class UserTest < ActiveSupport::TestCase end test "should not be possible to change the PIN if the confirmation does not match" do - user = Factory.create(:user) + user = FactoryGirl.create(:user) pin_salt = user.pin_salt pin_hash = user.pin_hash user.new_pin = '123001' @@ -67,7 +67,7 @@ class UserTest < ActiveSupport::TestCase end test "PIN must be numeric" do - user = Factory.create(:user) + user = FactoryGirl.create(:user) new_pin = 'xxxx' user.new_pin = new_pin user.new_pin_confirmation = new_pin -- cgit v1.2.3 From 648f51a0ac97675d6cdf6a4b0c3c75bc9ea23168 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 22:04:51 +0100 Subject: Undo the last commit. --- Gemfile.lock | 113 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 696166f..f9a6596 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,95 +28,95 @@ GEM activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) - acts_as_list (0.1.9) - addressable (2.3.2) + acts_as_list (0.1.5) + addressable (2.2.7) arel (3.0.2) bcrypt-ruby (3.0.1) - breadcrumbs_on_rails (2.3.0) - builder (3.0.4) - cancan (1.6.8) - carrierwave (0.7.1) - activemodel (>= 3.2.0) - activesupport (>= 3.2.0) - chunky_png (1.2.6) + breadcrumbs_on_rails (2.2.0) + builder (3.0.0) + cancan (1.6.7) + carrierwave (0.5.8) + activesupport (~> 3.0) + chunky_png (1.2.5) coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.4.0) - compass (0.12.2) + coffee-script-source (1.2.0) + compass (0.12.rc.1) chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.1) - compass-rails (1.0.3) - compass (>= 0.12.2, < 0.14) + compass-rails (1.0.0.rc.3) + compass (~> 0.12.rc.0) cookiejar (0.3.0) - delayed_job (3.0.4) + delayed_job (3.0.1) activesupport (~> 3.0) - delayed_job_active_record (0.3.3) - activerecord (>= 2.1.0, < 4) - delayed_job (~> 3.0) - em-http-request (1.0.3) + delayed_job_active_record (0.3.2) + activerecord (> 2.1.0) + delayed_job (~> 3.0.0) + em-http-request (1.0.1) addressable (>= 2.2.3) cookiejar em-socksify eventmachine (>= 1.0.0.beta.4) http_parser.rb (>= 0.5.3) - em-socksify (0.2.1) - eventmachine (>= 1.0.0.beta.4) + em-socksify (0.1.0) + eventmachine erubis (2.7.0) - eventmachine (1.0.0) - execjs (1.4.0) + eventmachine (1.0.0.beta.4) + execjs (1.3.0) multi_json (~> 1.0) - factory_girl (4.1.0) - activesupport (>= 3.0.0) - factory_girl_rails (4.1.0) - factory_girl (~> 4.1.0) + factory_girl (2.6.1) + activesupport (>= 2.3.9) + factory_girl_rails (1.7.0) + factory_girl (~> 2.6.0) railties (>= 3.0.0) - faye (0.8.6) + faye (0.8.0) cookiejar (>= 0.3.0) em-http-request (>= 0.3.0) eventmachine (>= 0.12.0) faye-websocket (>= 0.4.0) rack (>= 1.0.0) yajl-ruby (>= 1.0.0) - faye-websocket (0.4.6) + faye-websocket (0.4.1) eventmachine (>= 0.12.0) - fssm (0.2.9) + fssm (0.2.8.1) haml (3.1.7) hike (1.2.1) - hirb (0.7.0) + hirb (0.6.1) http_accept_language (1.0.2) http_parser.rb (0.5.3) - i18n (0.6.1) - journey (1.0.4) - jquery-rails (2.1.4) - railties (>= 3.0, < 5.0) - thor (>= 0.14, < 2.0) - json (1.7.5) + i18n (0.6.0) + journey (1.0.3) + jquery-rails (2.0.1) + railties (>= 3.2.0, < 5.0) + thor (~> 0.14) + json (1.6.5) + libv8 (3.3.10.4) macaddr (1.6.1) systemu (~> 2.5.0) - mail (2.4.4) + mail (2.4.3) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) - mime-types (1.19) + mime-types (1.17.2) mini_magick (3.4) subexec (~> 0.2.1) - multi_json (1.5.0) + multi_json (1.1.0) mysql2 (0.3.11) - nokogiri (1.5.6) + nokogiri (1.5.5) polyglot (0.3.3) - private_pub (1.0.3) + private_pub (1.0.1) faye rack (1.4.1) rack-cache (1.2) rack (>= 0.4) rack-ssl (1.3.2) rack - rack-test (0.6.2) + rack-test (0.6.1) rack (>= 1.0) rails (3.2.2) actionmailer (= 3.2.2) @@ -137,39 +137,38 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (~> 0.14.6) - rake (10.0.3) + rake (0.9.2.2) rdoc (3.12) json (~> 1.4) - ref (1.0.2) ruby-graphviz (0.9.21) - sass (3.2.4) - sass-rails (3.2.5) + sass (3.1.15) + sass-rails (3.2.4) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) simple_form (2.0.1) actionpack (~> 3.0) activemodel (~> 3.0) - sprockets (2.1.3) + sprockets (2.1.2) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.6) + sqlite3 (1.3.5) state_machine (1.1.2) - subexec (0.2.2) - systemu (2.5.2) - therubyracer (0.11.0) - ref + subexec (0.2.1) + systemu (2.5.1) + therubyracer (0.9.10) + libv8 (~> 3.3.10) thor (0.14.6) tilt (1.3.3) - treetop (1.4.12) + treetop (1.4.10) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.35) - uglifier (1.3.0) + tzinfo (0.3.32) + uglifier (1.2.3) execjs (>= 0.3.0) - multi_json (~> 1.0, >= 1.0.2) - uuid (2.3.6) + multi_json (>= 1.0.2) + uuid (2.3.5) macaddr (~> 1.0) will_paginate (3.0.3) yajl-ruby (1.1.0) -- cgit v1.2.3 From 9f14a9a6573db607b79124524088803812454515 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 22:15:58 +0100 Subject: Upgraded FactoryGirl gem --- Gemfile.lock | 105 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 52 insertions(+), 53 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 9336fe9..4e2ff46 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,95 +28,95 @@ GEM activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) - acts_as_list (0.1.9) - addressable (2.3.2) + acts_as_list (0.1.5) + addressable (2.2.7) arel (3.0.2) bcrypt-ruby (3.0.1) - breadcrumbs_on_rails (2.3.0) - builder (3.0.4) - cancan (1.6.8) - carrierwave (0.7.1) - activemodel (>= 3.2.0) - activesupport (>= 3.2.0) - chunky_png (1.2.6) + breadcrumbs_on_rails (2.2.0) + builder (3.0.0) + cancan (1.6.7) + carrierwave (0.5.8) + activesupport (~> 3.0) + chunky_png (1.2.5) coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.4.0) - compass (0.12.2) + coffee-script-source (1.2.0) + compass (0.12.rc.1) chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.1) compass-rails (1.0.0.rc.3) compass (~> 0.12.rc.0) cookiejar (0.3.0) - delayed_job (3.0.4) + delayed_job (3.0.1) activesupport (~> 3.0) - delayed_job_active_record (0.3.3) - activerecord (>= 2.1.0, < 4) - delayed_job (~> 3.0) - em-http-request (1.0.3) + delayed_job_active_record (0.3.2) + activerecord (> 2.1.0) + delayed_job (~> 3.0.0) + em-http-request (1.0.1) addressable (>= 2.2.3) cookiejar em-socksify eventmachine (>= 1.0.0.beta.4) http_parser.rb (>= 0.5.3) - em-socksify (0.2.1) - eventmachine (>= 1.0.0.beta.4) + em-socksify (0.1.0) + eventmachine erubis (2.7.0) - eventmachine (1.0.0) - execjs (1.4.0) + eventmachine (1.0.0.beta.4) + execjs (1.3.0) multi_json (~> 1.0) - factory_girl (4.1.0) - activesupport (>= 3.0.0) - factory_girl_rails (4.1.0) - factory_girl (~> 4.1.0) + factory_girl (2.6.4) + activesupport (>= 2.3.9) + factory_girl_rails (1.7.0) + factory_girl (~> 2.6.0) railties (>= 3.0.0) - faye (0.8.6) + faye (0.8.0) cookiejar (>= 0.3.0) em-http-request (>= 0.3.0) eventmachine (>= 0.12.0) faye-websocket (>= 0.4.0) rack (>= 1.0.0) yajl-ruby (>= 1.0.0) - faye-websocket (0.4.6) + faye-websocket (0.4.1) eventmachine (>= 0.12.0) - fssm (0.2.9) + fssm (0.2.8.1) haml (3.1.7) hike (1.2.1) - hirb (0.7.0) + hirb (0.6.1) http_accept_language (1.0.2) http_parser.rb (0.5.3) i18n (0.6.1) - journey (1.0.4) - jquery-rails (2.1.4) - railties (>= 3.0, < 5.0) - thor (>= 0.14, < 2.0) - json (1.7.5) + journey (1.0.3) + jquery-rails (2.0.1) + railties (>= 3.2.0, < 5.0) + thor (~> 0.14) + json (1.6.5) + libv8 (3.3.10.4) macaddr (1.6.1) systemu (~> 2.5.0) - mail (2.4.4) + mail (2.4.3) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) - mime-types (1.19) + mime-types (1.17.2) mini_magick (3.4) subexec (~> 0.2.1) multi_json (1.5.0) mysql2 (0.3.11) - nokogiri (1.5.6) + nokogiri (1.5.5) polyglot (0.3.3) - private_pub (1.0.3) + private_pub (1.0.1) faye rack (1.4.1) rack-cache (1.2) rack (>= 0.4) rack-ssl (1.3.2) rack - rack-test (0.6.2) + rack-test (0.6.1) rack (>= 1.0) rails (3.2.2) actionmailer (= 3.2.2) @@ -137,39 +137,38 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (~> 0.14.6) - rake (10.0.3) + rake (0.9.2.2) rdoc (3.12) json (~> 1.4) - ref (1.0.2) ruby-graphviz (0.9.21) - sass (3.2.4) - sass-rails (3.2.5) + sass (3.1.15) + sass-rails (3.2.4) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) simple_form (2.0.1) actionpack (~> 3.0) activemodel (~> 3.0) - sprockets (2.1.3) + sprockets (2.1.2) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.6) + sqlite3 (1.3.5) state_machine (1.1.2) - subexec (0.2.2) - systemu (2.5.2) - therubyracer (0.11.0) - ref + subexec (0.2.1) + systemu (2.5.1) + therubyracer (0.9.10) + libv8 (~> 3.3.10) thor (0.14.6) tilt (1.3.3) - treetop (1.4.12) + treetop (1.4.10) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.35) - uglifier (1.3.0) + tzinfo (0.3.32) + uglifier (1.2.3) execjs (>= 0.3.0) - multi_json (~> 1.0, >= 1.0.2) - uuid (2.3.6) + multi_json (>= 1.0.2) + uuid (2.3.5) macaddr (~> 1.0) will_paginate (3.0.3) yajl-ruby (1.1.0) -- cgit v1.2.3 From f5a512fe34fff50bcc7e96b57120d56a79ea47cb Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 22:25:52 +0100 Subject: Set a couple of :autofocus => true to make the UI better. --- app/views/call_forwards/_form_core.html.haml | 2 +- app/views/phone_numbers/_form_core.html.haml | 6 +++--- app/views/sip_accounts/_form_core.html.haml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/call_forwards/_form_core.html.haml b/app/views/call_forwards/_form_core.html.haml index 3dadb68..f75181f 100644 --- a/app/views/call_forwards/_form_core.html.haml +++ b/app/views/call_forwards/_form_core.html.haml @@ -1,5 +1,5 @@ .inputs - = f.input :call_forward_case_id, :as => :select, :collection => @available_call_forward_cases.map {|x| [I18n.t("call_forward_cases.#{x.value}"), x.id] }, :label => t('call_forwards.form.call_forward_case_id.label'), :hint => conditional_hint('call_forwards.form.call_forward_case_id.hint'), :include_blank => false + = f.input :call_forward_case_id, :as => :select, :collection => @available_call_forward_cases.map {|x| [I18n.t("call_forward_cases.#{x.value}"), x.id] }, :label => t('call_forwards.form.call_forward_case_id.label'), :hint => conditional_hint('call_forwards.form.call_forward_case_id.hint'), :include_blank => false, :autofocus => true = f.input :timeout, :label => t('call_forwards.form.timeout.label'), :hint => conditional_hint('call_forwards.form.timeout.hint') = f.input :call_forwarding_destination , :as => :select, :collection => @call_forwarding_destinations, :label => t('call_forwards.form.call_forwarding_destination.label'), :hint => conditional_hint('call_forwards.form.call_forwarding_destination.hint'), :include_blank => false diff --git a/app/views/phone_numbers/_form_core.html.haml b/app/views/phone_numbers/_form_core.html.haml index add3039..a1ce1f3 100644 --- a/app/views/phone_numbers/_form_core.html.haml +++ b/app/views/phone_numbers/_form_core.html.haml @@ -2,9 +2,9 @@ - if @phone_book_entry = f.input :name, :collection => ['Office', 'Home', 'Mobile', 'Fax'], :include_blank => false, :label => t('phone_numbers.form.name.label'), :hint => conditional_hint('phone_numbers.form.name.hint') - = f.input :number, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint') + = f.input :number, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint'), :autofocus => true - else - if @callthrough || @hunt_group_member || @access_authorization || @current_user.current_tenant.array_of_available_internal_extensions_and_dids.count == 0 || @current_user.current_tenant.array_of_available_internal_extensions_and_dids.count > 250 - = f.input :number, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint') + = f.input :number, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint'), :autofocus => true - else - = f.input :number, :collection => @current_user.current_tenant.array_of_available_internal_extensions_and_dids, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint'), :include_blank => false + = f.input :number, :collection => @current_user.current_tenant.array_of_available_internal_extensions_and_dids, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint'), :include_blank => false, :autofocus => true diff --git a/app/views/sip_accounts/_form_core.html.haml b/app/views/sip_accounts/_form_core.html.haml index dbd27fe..6a63da6 100644 --- a/app/views/sip_accounts/_form_core.html.haml +++ b/app/views/sip_accounts/_form_core.html.haml @@ -1,7 +1,7 @@ .inputs = f.input :auth_name, :as => :string, :label => t('sip_accounts.form.auth_name.label'), :hint => conditional_hint('sip_accounts.form.auth_name.hint') = f.input :password, :as => :string, :label => t('sip_accounts.form.password.label'), :hint => conditional_hint('sip_accounts.form.password.hint') - = f.input :caller_name, :as => :string, :label => t('sip_accounts.form.caller_name.label'), :hint => conditional_hint('sip_accounts.form.caller_name.hint') + = f.input :caller_name, :as => :string, :label => t('sip_accounts.form.caller_name.label'), :hint => conditional_hint('sip_accounts.form.caller_name.hint'), :autofocus => true = f.input :voicemail_pin, :as => :string, :label => t('sip_accounts.form.voicemail_pin.label'), :hint => conditional_hint('sip_accounts.form.voicemail_pin.hint') = f.input :call_waiting, :label => t('sip_accounts.form.call_waiting.label'), :hint => conditional_hint('sip_accounts.form.call_waiting.hint') = f.input :clir, :label => t('sip_accounts.form.clir.label'), :hint => conditional_hint('sip_accounts.form.clir.hint') -- cgit v1.2.3 From 12c8f4c82770ded6ea6b519e4451ed6757419ddf Mon Sep 17 00:00:00 2001 From: Sascha Daniels Date: Mon, 31 Dec 2012 02:09:05 +0100 Subject: Remove unused ontroller --- app/controllers/config_siemens_sort_controller.rb | 371 ---------------------- 1 file changed, 371 deletions(-) delete mode 100644 app/controllers/config_siemens_sort_controller.rb diff --git a/app/controllers/config_siemens_sort_controller.rb b/app/controllers/config_siemens_sort_controller.rb deleted file mode 100644 index c0739e5..0000000 --- a/app/controllers/config_siemens_sort_controller.rb +++ /dev/null @@ -1,371 +0,0 @@ -require 'nokogiri' -#doc.search('Message/ItemList').each do |a| puts a.children end -class ConfigSiemensController < ApplicationController -#TODO Authentication - # No access for admins though as this contains personal data. - - # We can't use load_and_authorize_resource() here because - # ConfigSiemensController isn't a resource. - # We can try client certificates - - skip_authorization_check - - - def index - os40_keys=7 - os60_keys=8 - os80_keys=9 - doc = Nokogiri::XML(request.body.read) - #logger.debug("#{params[:WorkpointMessage].to_xml}") - #logger.debug("#{params[:WorkpointMessage][:Message][:ItemList].to_xml}") - @phone_items=Hash.new - contact_reason = params[:WorkpointMessage][:Message][:ReasonForContact] - reply_status = doc.search('Message/ReasonForContact').first[:status] - reply_action = doc.search('Message/ReasonForContact').first[:action] - - doc.search('Message/ItemList/Item').each do |post_item| - @phone_items[post_item[:name]]=post_item.children.to_s - end - - mac_address = @phone_items['mac-addr'] - phone_type = @phone_items['device-type'] - if phone_type == "OpenStage 40" - max_keys = (os40_keys) * 2 - elsif phone_type == "OpenStage 60" - max_keys = (os60_keys) * 2 - elsif phone_type == "OpenStage 80" - max_keys = (os80_keys) * 2 - else - max_keys = 0 - end - - blf_keys_max = max_keys / 2 - shift_key_position = blf_keys_max - 1 - - #logger.debug(request.body.read) - @phone = Phone.find_by_mac_address(mac_address.gsub(':','').upcase) - if ! @phone.nil? - @phone.update_attributes(:ip_address => request.remote_ip) - sip_account = SipAccount.where(:sip_accountable_type == @phone.phoneable_type, - :sip_accountable_id == @phone.phoneable_id).first - end - - if ! @phone.nil? && ! sip_account.nil? - #logger.debug(@phone_items) - @my_nonce = params[:WorkpointMessage][:Message][:nonce] - @new_settings = Array.new - - @new_settings << ['dhcp', nil, 'true'] - @new_settings << ['hostname', nil, mac_address.gsub(':', '') ] - @new_settings << ['e164-hostname', nil, 'false'] - @new_settings << ['mobility-enabled', nil, 'false'] - @new_settings << ['mobility-password-on-logoff', nil, 'false'] - @new_settings << ['e164', nil, sip_account.try(:phone_numbers).first.number] - @new_settings << ['sip-user-id', nil, sip_account.auth_name] - @new_settings << ['reg-id', nil, sip_account.auth_name] - @new_settings << ['reg-number', nil, sip_account.auth_name] - @new_settings << ['fully-qualified-phone-no', nil, sip_account.auth_name] - @new_settings << ['sip-pwd', nil, sip_account.password] - @new_settings << ['sip-name', nil, sip_account.caller_name] - @new_settings << ['register-by-name', nil, 'false'] - #OPTIMIZE Display ID ? - @new_settings << ['display-id', nil, sip_account.try(:phone_numbers).first.number] - @new_settings << ['display-id-unicode', nil, sip_account.caller_name] - @new_settings << ['use-display-id', nil, 'true'] - @new_settings << ['reg-addr', nil, sip_account.sip_domain.host] - @new_settings << ['reg-port', nil, '5060'] - @new_settings << ['registrar-addr', nil, sip_account.sip_domain.host] - @new_settings << ['registrar-port', nil, '5060'] - @new_settings << ['outbound-proxy', nil, sip_account.sip_domain.host] - @new_settings << ['outbound-proxy-user', nil, sip_account.sip_domain.host] - @new_settings << ['sgnl-gateway-addr', nil, sip_account.sip_domain.host] - @new_settings << ['sgnl-gateway-addr-user', nil, sip_account.sip_domain.host] - @new_settings << ['sgnl-gateway-port', nil, '5060' ] - @new_settings << ['sgnl-gateway-port-user', nil, '5060'] - @new_settings << ['sgnl-route', nil, '0' ] - @new_settings << ['mwi-e164', nil, '' ] - @new_settings << ['rtp-base-port', nil, '5004'] - @new_settings << ['default-domain', nil, '' ] - @new_settings << ['sip-transport', nil, '0' ] - @new_settings << ['sip-transport-user', nil, '0' ] - @new_settings << ['server-type', nil, '0' ] - @new_settings << ['session-timer', nil, 'true'] - @new_settings << ['session-duration', nil, '3600' ] - @new_settings << ['reg-ttl', nil, '3600' ] - @new_settings << ['realm', nil, sip_account.sip_domain.realm] - @new_settings << ['emergency-e164', nil, '0110' ] - @new_settings << ['voice-mail-e164', nil, 'voicemail'] - @new_settings << ['auto-answer', nil, 'false'] - @new_settings << ['beep-on-auto-answer', nil, 'true'] - @new_settings << ['auto-reconnect', nil, 'false' ] - @new_settings << ['beep-on-auto-reconnect', nil, 'true'] - @new_settings << ['permit-decline-call', nil, 'true'] - @new_settings << ['transfer-on-ring', nil, 'false' ] - @new_settings << ['join-allowed-in-conference', nil, 'true'] - @new_settings << ['pickup-group-uri', nil, '*8*'] - @new_settings << ['pickup-group-uri', nil, '' ] - @new_settings << ['hot-line-warm-line-digits', nil, '' ] - @new_settings << ['initial-digit-timer', nil, '30' ] - @new_settings << ['conference-factory-uri', nil, ''] - @new_settings << ['callback-busy-allow', nil, 'false'] - @new_settings << ['callback-busy-code', nil, '' ] - @new_settings << ['callback-ring-allow', nil, 'false'] - @new_settings << ['callback-ring-code', nil, ''] - @new_settings << ['callback-cancel-code', nil, ''] - @new_settings << ['park-server', nil, ''] - #OPTIMIZE Callwaiting - @new_settings << ['call-waiting-enabled', nil, 'true'] - @new_settings << ['qos-layer2', nil, 'true'] - @new_settings << ['l2qos-voice', nil, '5' ] - @new_settings << ['l2qos-signalling', nil, '3' ] - @new_settings << ['l2qos-default', nil, '0'] - @new_settings << ['qos-layer3', nil, 'true'] - @new_settings << ['l3qos-voice', nil, '46'] - @new_settings << ['l3qos-signalling', nil, '26'] - @new_settings << ['vlan-method', nil, '1'] - #OPTIMIZE Timezone - @new_settings << ['sntp-tz-offset', nil, ''] - @new_settings << ['daylight-save', nil, ''] - @new_settings << ['daylight-save-minutes', nil, ''] - #OPTIMIZE Use SNMP? - @new_settings << ['snmp-trap-addr', nil, ''] - @new_settings << ['snmp-trap-port', nil, ''] - @new_settings << ['snmp-trap-pwd', nil, 'snmp' ] - @new_settings << ['snmp-traps-active', nil, 'false' ] - @new_settings << ['diagnostic-trap-addr', nil, ''] - @new_settings << ['diagnostic-trap-port', nil, ''] - @new_settings << ['diagnostic-trap-pwd', nil, 'snmp' ] - @new_settings << ['diagnostic-traps-active', nil, 'false' ] - @new_settings << ['diagnostic-snmp-active', nil, 'false'] - @new_settings << ['qdc-collection-unit-addr', nil, ''] - @new_settings << ['qdc-collection-unit-port', nil, '12010'] - - @new_settings << ['qdc-trap-pwd', nil, 'QOSDC'] - @new_settings << ['qdc-snmp-active', nil, 'false'] - @new_settings << ['qdc-qcu-active', nil, 'false'] - @new_settings << ['snmp-queries-allowed', nil, 'false'] - @new_settings << ['snmp-pwd', nil, ''] - @new_settings << ['disable-microphone', nil, 'false'] - @new_settings << ['loudspeech-enabled', nil, 'true'] - @new_settings << ['audio-silence-suppression', nil, 'false'] - - @new_settings << ['port1', nil, '0' ] # 0=Automatic (speed) - @new_settings << ['port2', nil, '0' ] - @new_settings << ['port2-mode', nil, '1' ] - @new_settings << ['port2-auto-mdix-enabled', nil, 'true' ] - @new_settings << ['originating-line-preference', nil, '0'] - @new_settings << ['terminating-line-preference', nil, '0'] - @new_settings << ['line-key-operating-mode', nil, '0'] - @new_settings << ['line-rollover-type', nil, '2'] - @new_settings << ['line-rollover-volume', nil, '5' ]# 1-5 - @new_settings << ['line-registration-leds', nil, 'true'] - @new_settings << ['keyset-use-focus', nil, 'true' ] - @new_settings << ['keyset-remote-forward-ind', nil, 'true'] - @new_settings << ['keyset-reservation-timer', nil, '60' ] # 0-300 - @new_settings << ['dial-plan-enabled', nil, '' ] - @new_settings << ['Canonical-dialing-international-prefix', nil, ''] - @new_settings << ['Canonical-dialing-local-country-code', nil, ''] - @new_settings << ['Canonical-dialing-national-prefix', nil, ''] - @new_settings << ['Canonical-dialing-local-area-code', nil, ''] - @new_settings << ['Canonical-dialing-local-node', nil, ''] - @new_settings << ['Canonical-dialing-external-access', nil, '0'] - @new_settings << ['Canonical-dialing-operator-code', nil, ''] - @new_settings << ['Canonical-dialing-emergency-number', nil, ''] - @new_settings << ['Canonical-dialing-dial-needs-access-code', nil, '0'] - @new_settings << ['Canonical-dialing-dial-needs-intGWcode', nil, '0'] - @new_settings << ['Canonical-dialing-min-local-number-length', nil, '10'] - @new_settings << ['Canonical-dialing-extension-initial-digits', nil, ''] - @new_settings << ['Canonical-dialing-dial-internal-form', nil, '0' ] - @new_settings << ['Canonical-dialing-dial-external-form', nil, '0' ] - @new_settings << ['Canonical-lookup-local-code', nil, '' ] - @new_settings << ['Canonical-lookup-international-code', nil, ''] - @new_settings << ['hot-keypad-dialing', nil, ''] - @new_settings << ['ldap-transport', nil, '0'] - @new_settings << ['ldap-server-address', nil, '' ] - @new_settings << ['ldap-server-port', nil, '389' ] - @new_settings << ['ldap-authentication', nil, '1'] - @new_settings << ['ldap-user', nil, '' ] - @new_settings << ['ldap-pwd', nil, '' ] - @new_settings << ['ldap-max-responses', nil, '25'] - @new_settings << ['backup-addr', nil, ''] - @new_settings << ['backup-registration', nil, 'false'] - @new_settings << ['qdc-qcu-active', nil, 'false' ] - @new_settings << ['min-admin-passw-length', nil, '6' ] - @new_settings << ['default-locked-config-menus', nil, 'true' ] - @new_settings << ['locked-config-menus', nil, 'true' ] - @new_settings << ['default-locked-local-function-menus', nil, 'true' ] - @new_settings << ['locked-local-function-menus', nil, 'true' ] - @new_settings << ['dls-mode-secure', nil, '0' ] - @new_settings << ['dls-chunk-size', nil, '9492'] - @new_settings << ['default-passw-policy', nil, 'false'] - @new_settings << ['deflect-destination', nil, ''] - @new_settings << ['display-skin', nil, ''] - @new_settings << ['enable-bluetooth-interface', nil, 'true'] - @new_settings << ['usb-access-enabled', nil, 'false' ] - @new_settings << ['usb-backup-enabled', nil, 'false' ] - @new_settings << ['line-button-mode', nil, '0' ] - @new_settings << ['lock-forwarding', nil, '' ] - @new_settings << ['loudspeaker-function-mode', nil, '0' ] - @new_settings << ['max-pin-retries', nil, '' ] - @new_settings << ['inactivity-timeout', nil, '30' ] - @new_settings << ['not-used-timeout', nil, '2' ] - @new_settings << ['passw-char-set', nil, '0' ] - @new_settings << ['refuse-call', nil, 'true' ] - @new_settings << ['restart-password', nil, ''] - #OPTIMIZE clock format - @new_settings << ['time-format', nil, '0' ]# 1=12 h - @new_settings << ['uaCSTA-enabled', nil, 'false' ] - @new_settings << ['enable-test-interface', nil, 'false'] - @new_settings << ['enable-WBM', nil, 'true'] - @new_settings << ['pixelsaver-timeout', nil, '2' ]# 2 hours? - @new_settings << ['voice-message-dial-tone', nil, '' ] - @new_settings << ['call-pickup-allowed', nil, 'true' ] - @new_settings << ['group-pickup-tone-allowed', nil, 'true'] - @new_settings << ['group-pickup-as-ringer', nil, 'false'] - @new_settings << ['group-pickup-alert-type', nil, '0' ] - @new_settings << ['default-profile', nil, '' ] - @new_settings << ['count-medium-priority', nil, '5'] - @new_settings << ['timer-medium-priority', nil, '60'] # 1 - 999 - @new_settings << ['timer-high-priority', nil, '5'] # 0 - 999 - @new_settings << ['dss-sip-detect-timer', nil, '10'] - @new_settings << ['dss-sip-deflect', nil, 'false' ] - @new_settings << ['dss-sip-refuse', nil, 'false' ] - @new_settings << ['feature-availability', nil, 'false'] - @new_settings << ['feature-availability', nil, 'true' ] - @new_settings << ['feature-availability', nil, 'true' ] - @new_settings << ['local-control-feature-availability', nil, 'false' ] - @new_settings << ['trace-level', nil, '0' ] # Off - @new_settings << ['default-locked-function-keys', nil, 'true' ]# "unknown item" - #OPTIMIZE Put pickup prefix into database/global constant? - @new_settings << ['blf-code', nil, 'f_ia_'] # pickup prefix for softkey function 59 (BLF) - @new_settings << ['stimulus-feature-code', nil, true] - @new_settings << ['stimulus-led-control-uri', nil, true] - - - @new_settings << ['min-user-passw-length', nil, '6' ]# 6 - 24 - #OPTIMIZE language - @new_settings << ['country-iso', nil, 'DE' ] - @new_settings << ['language-iso', nil, 'de'] - @new_settings << ['date-format', nil, '0' ] # DD.MM.YYYY - #OPTIMIZE ringtones - @new_settings << ['ringer-melody', nil, '1'] - - @new_settings << ['ringer-melody', nil, '2'] - @new_settings << ['ringer-tone-sequence', nil, '2'] - - soft_keys = Array.new - # Getting BLF keys only for the first level - blf_keys = sip_account.softkeys.find( - :all, - :conditions => {:function => ['blf', 'conference']}, - :limit => blf_keys_max) - #Getting other keys - non_blf_keys = sip_account.softkeys.find( - :all, - :conditions => {:function => ['speed_dial']}) - - # Fill softkey array with BLF keys up to shift key - blf_keys.each do |k| - soft_keys << k - end - # Fill sofkey with other keys up to end - non_blf_keys.each do |k| - if soft_keys.length < max_keys - soft_keys << k - end - end - # Delete unset softkeys - while soft_keys.length < max_keys - soft_keys << Softkey.new - end - - key_pos=1 - - #soft_keys.each do |sk| - - while key_pos < shift_key_position - - (1..shift_key_position-1).each do |key_idx| - sk = soft_keys.shift - logger.debug(sk.function, key_idx) - if sk.function == "blf" - @new_settings << ['function-key-def', key_idx, '59'] - @new_settings << ['select-dial', key_idx, sk.number ] - elsif sk.function == "log_out" - @new_settings << ['function-key-def', key_idx, '1'] - @new_settings << ['select-dial', key_idx, 'f_lo' ] - elsif sk.function == "log_in" - @new_settings << ['function-key-def', key_idx, '1'] - @new_settings << ['select-dial', key_idx, "f_li_#{sk.number}" ] - elsif sk.function == "dtmf" - @new_settings << ['function-key-def', key_idx, '54'] - @new_settings << ['stimulus-DTMF-sequence', key_idx, sk.number ] - elsif sk.function.nil? - @new_settings << ['function-key-def', key_idx, '0'] - else - @new_settings << ['function-key-def', key_idx, '1'] - @new_settings << ['select-dial', key_idx, sk.number ] - end - @new_settings << ['key-label', key_idx, sk.label ] - @new_settings << ['key-label-unicode', key_idx, sk.label ] - key_pos = key_pos+1 - - end - end - if key_pos == shift_key_position - @new_settings << ['function-key-def', shift_key_position, '18'] - @new_settings << ['key-label', shift_key_position, 'Shift'] - @new_settings << ['key-label-unicode', shift_key_position, 'Shift'] - key_pos = key_pos+1 - end - - (1001..1000+shift_key_position-1).each do |key_idx| - sk = soft_keys.shift - if sk.function == "log_out" - @new_settings << ['function-key-def', key_idx, '1'] - @new_settings << ['select-dial', key_idx, 'f_lo' ] - elsif sk.function == "log_in" - @new_settings << ['function-key-def', key_idx, '1'] - @new_settings << ['select-dial', key_idx, "f_li_#{sk.number}" ] - elsif sk.function == "dtmf" - @new_settings << ['function-key-def', key_idx, '54'] - @new_settings << ['stimulus-DTMF-sequence', key_idx, sk.number ] - elsif sk.function.nil? - @new_settings << ['function-key-def', key_idx, '0'] - else - @new_settings << ['function-key-def', key_idx, '1'] - @new_settings << ['select-dial', key_idx, sk.number ] - end - @new_settings << ['key-label', key_idx, sk.label ] - @new_settings << ['key-label-unicode', key_idx, sk.label ] - key_pos = key_pos+1 - - end - - #end - logger.debug(@new_settings) - end - - if @phone.nil? || sip_account.nil? - respond_to { |format| - format.xml { render :action => "clean-up" } - } - - elsif (reply_status == 'accepted' && contact_reason == 'reply-to' && reply_action == 'ReadAllItems') - respond_to { |format| - format.xml { render :action => "write" } - } - - elsif ["reply-to"].include? contact_reason - respond_to { |format| - format.xml { render :action => "clean-up" } - } - - else - respond_to { |format| - format.xml { render :action => "index" } - } - end - - end -end -- cgit v1.2.3