Merge branch 'master' of https://github.com/ZeusWPI/Tap into interface

This commit is contained in:
tl3ilaxu 2016-02-11 16:27:20 +01:00
commit fab824fad3
24 changed files with 358 additions and 94 deletions

1
.gitignore vendored
View file

@ -6,6 +6,7 @@
# Ignore bundler config.
/.bundle
/vendor
# Ignore the default SQLite database.
/db/*.sqlite3

View file

@ -1 +1 @@
2.2.3
2.3.0-dev

View file

@ -6,6 +6,7 @@ gem 'rails', '4.2.4'
# Assets
gem 'sass-rails', '~> 4.0.3'
gem 'bootstrap-sass', '3.2.0.0'
gem 'bootstrap-switch-rails'
gem 'uglifier', '>= 1.3.0'
gem 'jquery-rails'
# Haml for templating!
@ -22,13 +23,14 @@ group :doc do
end
group :production do
gem 'mysql2' # Database
gem 'mysql2', '~> 0.3.18' # Database
end
group :test do
gem 'codeclimate-test-reporter', require: nil
gem 'rspec-rails'
gem 'coveralls', require: false
gem 'webmock'
end
group :development do

View file

@ -36,6 +36,7 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.4.0)
airbrake (4.3.5)
builder
multi_json
@ -44,9 +45,9 @@ GEM
rake (~> 10.4)
arel (6.0.3)
bcrypt (3.1.10)
bcrypt (3.1.10-x64-mingw32)
bootstrap-sass (3.2.0.0)
sass (~> 3.2)
bootstrap-switch-rails (3.3.3)
bootstrap-will_paginate (0.0.10)
will_paginate
builder (3.2.2)
@ -90,6 +91,8 @@ GEM
term-ansicolor (~> 1.3)
thor (~> 0.19.1)
tins (~> 1.6.0)
crack (0.4.3)
safe_yaml (~> 1.0.0)
daemons (1.2.3)
delayed_job (4.1.1)
activesupport (>= 3.0, < 5.0)
@ -111,14 +114,13 @@ GEM
execjs (2.6.0)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.5.0)
factory_girl_rails (4.6.0)
factory_girl (~> 4.5.0)
railties (>= 3.0.0)
faker (1.4.2)
i18n (~> 0.5)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
ffi (1.9.10-x64-mingw32)
friendly_id (5.1.0)
activerecord (>= 4.0.0)
globalid (0.3.6)
@ -131,6 +133,7 @@ GEM
haml (>= 4.0.6, < 5.0)
html2haml (>= 1.0.1)
railties (>= 4.0.1)
hashdiff (0.2.3)
hashie (3.4.3)
hike (1.2.3)
html2haml (2.0.0)
@ -163,16 +166,13 @@ GEM
multi_json (1.11.2)
multi_xml (0.5.5)
multipart-post (2.0.0)
mysql2 (0.4.2)
mysql2 (0.4.2-x64-mingw32)
mysql2 (0.3.20)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (3.0.2)
netrc (0.11.0)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
nokogiri (1.6.7.2-x64-mingw32)
mini_portile2 (~> 2.0.0.rc2)
oauth2 (1.1.0)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0, < 1.5.2)
@ -186,7 +186,7 @@ GEM
oauth2 (~> 1.0)
omniauth (~> 1.2)
orm_adapter (0.5.0)
paperclip (4.3.3)
paperclip (4.3.4)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
cocaine (~> 0.5.5)
@ -228,11 +228,6 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rest-client (1.8.0-x64-mingw32)
ffi (~> 1.9)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rspec-core (3.4.2)
rspec-support (~> 3.4.0)
rspec-expectations (3.4.0)
@ -241,7 +236,7 @@ GEM
rspec-mocks (3.4.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-rails (3.4.1)
rspec-rails (3.4.2)
actionpack (>= 3.0, < 4.3)
activesupport (>= 3.0, < 4.3)
railties (>= 3.0, < 4.3)
@ -252,6 +247,7 @@ GEM
rspec-support (3.4.1)
ruby_parser (3.7.3)
sexp_processor (~> 4.1)
safe_yaml (1.0.4)
sass (3.2.19)
sass-rails (4.0.5)
railties (>= 4.0.0, < 5.0)
@ -262,7 +258,7 @@ GEM
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
sexp_processor (4.6.1)
simplecov (0.11.1)
simplecov (0.11.2)
docile (~> 1.1.0)
json (~> 1.8)
simplecov-html (~> 0.10.0)
@ -278,7 +274,6 @@ GEM
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.11)
sqlite3 (1.3.11-x64-mingw32)
sshkit (1.8.1)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
@ -297,20 +292,23 @@ GEM
json (>= 1.8.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.1)
unf_ext (0.0.7.1-x64-mingw32)
unf_ext (0.0.7.2)
warden (1.2.6)
rack (>= 1.0)
webmock (1.22.6)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
will_paginate (3.0.7)
PLATFORMS
ruby
x64-mingw32
DEPENDENCIES
airbrake (~> 4)
annotate
bootstrap-sass (= 3.2.0.0)
bootstrap-switch-rails
bootstrap-will_paginate (= 0.0.10)
cancancan
capistrano (~> 3.1)
@ -331,7 +329,7 @@ DEPENDENCIES
httparty
identicon
jquery-rails
mysql2
mysql2 (~> 0.3.18)
omniauth-oauth2 (= 1.3.1)
paperclip
rails (= 4.2.4)
@ -342,7 +340,8 @@ DEPENDENCIES
sqlite3
turbolinks
uglifier (>= 1.3.0)
webmock
will_paginate (= 3.0.7)
BUNDLED WITH
1.10.6
1.11.2

View file

@ -13,6 +13,7 @@
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require bootstrap-switch
//= require turbolinks
//= require_tree .

View file

@ -0,0 +1,13 @@
ready = function() {
$('[data-switch]').bootstrapSwitch({ onText: "private", offText: "public" });
$('[data-switch]').on('switchChange.bootstrapSwitch', function(event, state) {
$(this).closest('form').submit();
});
$('#edit_user_1').on("ajax:error", function(xhr, status, error) {
alert("An error occured. Your account has not been updated.");
});
}
$(document).ready(ready);
$(document).on('page:load', ready);

View file

@ -16,8 +16,10 @@
@import "bootstrap-sprockets";
@import "bootstrap3-switch";
@import "bootstrap";
/* mixins, variables, etc. */
$gray-medium-light: #eaeaea;
@ -38,6 +40,10 @@ $gray-medium-light: #eaeaea;
text-align: center;
}
.float-right{
float: right;
}
.form-field{
margin-bottom: 15px;
text-align: bottom;

View file

@ -40,3 +40,7 @@
div.out-of-stock {
border-color:red;
}
.expand {
overflow: hidden;
}

View file

@ -5,16 +5,29 @@ class UsersController < ApplicationController
def show
end
def edit
end
def update
if @user.update_attributes(user_params)
flash[:success] = "Successfully updated!"
if user_params.empty?
flash[:notice] = "Nothing happened."
redirect_to @user
else
@user.reload
render 'edit'
if @user.update_attributes(user_params)
respond_to do |format|
format.html do
flash[:success] = "Successfully updated!"
redirect_to @user
end
format.js { head :ok }
end
else
respond_to do |format|
format.html do
flash[:error] = "Update failed!"
@user.reload
render 'show'
end
format.js { head :bad_request }
end
end
end
end
@ -38,10 +51,10 @@ class UsersController < ApplicationController
private
def user_params
params.require(:user).permit(:avatar, :private, :dagschotel_id)
params.fetch(:user, {}).permit(:avatar, :private, :dagschotel_id)
end
def init
@user = User.find_by_id(params[:id]) || current_user
@user ||= current_user
end
end

View file

@ -25,7 +25,9 @@ class Ability
def initialize_user(user)
can :read, :all
can :manage, User, id: user.id
can :create, Order, user: user
can :create, Order do |order|
order.user == user
end
can :destroy, Order do |order|
order.try(:user) == user && order.deletable
end

View file

@ -13,7 +13,6 @@
.hidden-xs.navbar-form.navbar-right
= render 'layouts/session_button'
%ul.nav.navbar-nav.navbar-right
%li= mail_to "tab@zeus.ugent.be", "Send feedback"
- if user_signed_in?
- if can? :manage, :all
%li.dropdown
@ -24,12 +23,8 @@
%li= link_to "List", products_path
%li= link_to "Add product" , barcode_products_path
%li= link_to "Barcodes", barcodes_path
%li.dropdown
%a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"}
Logged in as #{current_user.name}
%b.caret
%ul.dropdown-menu
%li= link_to "Edit profile", edit_user_path(current_user)
%li
%p.navbar-text Logged in as #{current_user.name}
%li
%p.navbar-text
Balance:

View file

@ -7,6 +7,6 @@
= image_tag user.avatar(:small), class: "img-responsive img-circle img-thumbnail"
.col-md-11
.row.text-center.guest
=link_to "Not a Zeus Account? Order as a guest.", new_guest_order_path, class: "btn btn-default btn-lg"
=link_to "Not a Zeus Account? Order as a guest.", new_user_order_path(User.guest), class: "btn btn-default btn-lg"
.row
= render @users

View file

@ -1,4 +1,4 @@
%div{role: "tabpanel"}
.expand{role: "tabpanel"}
/ Nav tabs
%ul.nav.nav-tabs{role: "tablist"}
%li.active{role: "presentation"}

View file

@ -1,10 +1,9 @@
.col-sm-3
%div
%h2
%h2.float-right
= content_tag :div, image_tag(@user.avatar, class: "img-circle img-thumbnail center"), class: "user_avatar center"
%h2.center
= @user.name
- if can? :edit, @user
= link_to content_tag(:small, content_tag(:span, "", class: "glyphicon glyphicon-cog")), edit_user_path(@user)
= content_tag :div, image_tag(@user.avatar, class: "img-circle img-thumbnail center"), class: "user_avatar center"
%ul.list-group
%li.list-group-item.text-muted Orders
%li.list-group-item
@ -15,12 +14,22 @@
%span.badge= @user.products_group_by_id.map(&:count).sum
- if can? :create, @user.orders.build
%li.list-group-item= link_to "Place new order", new_user_order_path(@user), class: "btn btn-default btn-block"
= render 'errors', object: @user
- if can? :edit, @user
%ul.list-group
%li.list-group-item.text-muted
- if @user.dagschotel
Huidige dagschotel
\#{image_tag @user.dagschotel.avatar}
.center
%p= image_tag @user.dagschotel.avatar, title: "Huidige dagschotel"
\#{link_to "Change dagschotel", edit_dagschotel_user_path(@user), class: "btn btn-default btn-block"}
- else
= link_to "Set dagschotel", edit_dagschotel_user_path(@user), class: "btn btn-default btn-block"
%li.list-group-item.text-muted
%p Orders can be placed on koelkast for every public account. Private accounts can only order products by logging in here.
= f_form_for @user, remote: true do |f|
.center
= f.check_box :private, skip_label: true, data: { switch: true }
%li.list-group-item.text-muted
= f_form_for @user do |f|
= f.file_field :avatar, skip_label: true
= f.submit "Change avatar", class: "btn btn-default btn-block"

View file

@ -1,13 +0,0 @@
.row
= render 'sidebar'
.col-sm-9
%h2 Edit your settings
= f_form_for @user do |f|
= f.error_messages
= f.file_field :avatar
%p
If you check this option, nobody will be able to order stuff for you through koelkast.
Only on your account things can be ordered.
%p
= f.check_box :private
= f.submit "Update"

View file

@ -21,6 +21,6 @@ module Tab002
# config.i18n.default_locale = :de
config.active_record.raise_in_transactional_callbacks = true
config.active_job.queue_adapter = :delayed_job
config.call_api_after = 5.seconds
config.call_api_after = 5.minutes
end
end

View file

@ -42,4 +42,6 @@ Rails.application.configure do
Paperclip.options[:command_path] = "/usr/local/bin/"
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.api_url = "http://www.example.com"
end

View file

@ -17,7 +17,7 @@ Rails.application.routes.draw do
end
end
resources :users, only: [:show, :edit, :update] do
resources :users, only: [:show, :update] do
resources :orders, only: [:new, :create, :destroy]
member do
get 'quickpay' => 'users#quickpay'

View file

@ -34,28 +34,6 @@ describe UsersController, type: :controller do
end
end
##########
# EDIT #
##########
describe 'GET edit' do
before :each do
get :edit, id: @user
end
it 'should be successful' do
expect(response).to have_http_status(200)
end
it 'should render the form' do
expect(response).to render_template(:edit)
end
it 'should load the correct user' do
expect(assigns(:user)).to eq(@user)
end
end
############
# UPDATE #
############
@ -67,10 +45,11 @@ describe UsersController, type: :controller do
end
context 'successful' do
it 'should update attributes' do
it 'should update privacy' do
new_private = !(@user.private)
put :update, id: @user, user: { private: new_private }
expect(@user.reload.private).to be new_private
expect(flash[:success]).to be_present
end
it 'should update dagschotel' do
@ -78,6 +57,25 @@ describe UsersController, type: :controller do
put :update, id: @user, user: { dagschotel_id: product.id }
expect(@user.reload.dagschotel).to eq(product)
end
it 'should accept real images' do
file = fixture_file_upload('files/real-image.png', 'image/png')
put :update, id: @user, user: { avatar: file }
expect(flash[:success]).to be_present
end
end
context 'danger zone' do
it 'should warn for NOPs' do
put :update, id: @user, user: {}
expect(flash[:notice]).to be_present
end
it 'should not accept unreal images' do
file = fixture_file_upload('files/unreal-image.svg', 'image/svg+xml')
put :update, id: @user, user: { avatar: file }
expect(flash[:error]).to be_present
end
end
end

View file

@ -24,7 +24,7 @@ require 'identicon'
FactoryGirl.define do
factory :user do
name { Faker::Name.name }
name { Faker::Internet.user_name }
avatar { Identicon.data_url_for name }
private { false }

BIN
spec/fixtures/files/real-image.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

182
spec/fixtures/files/unreal-image.svg vendored Normal file
View file

@ -0,0 +1,182 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="126.86385mm"
height="129.21333mm"
viewBox="0 0 449.51759 457.84252"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="unreal-image.svg"
inkscape:export-filename="/home/felix/real-image.png"
inkscape:export-xdpi="179.99899"
inkscape:export-ydpi="179.99899">
<defs
id="defs4">
<clipPath
id="clipPath3464"
clipPathUnits="userSpaceOnUse">
<rect
y="719.15387"
x="594.10657"
height="446.3454"
width="308.96982"
id="rect3466"
style="opacity:1;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</clipPath>
<clipPath
id="clipPath4382"
clipPathUnits="userSpaceOnUse">
<path
inkscape:connector-curvature="0"
id="path4384"
d="M 548.67975,395.83302 527.01742,668.18928 383.49652,551.67654 Z"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#ff00ff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
</clipPath>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="92.586293"
inkscape:cy="194.15587"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1366"
inkscape:window-height="750"
inkscape:window-x="0"
inkscape:window-y="18"
inkscape:window-maximized="0" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-312.13672,-477.34107)">
<path
style="opacity:1;fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:8.19999981;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
d="M 536.89454,486.67773 A 224.75894,224.25386 0 0 1 761.6543,710.92969 224.75894,224.25386 0 0 1 536.89454,935.18359 224.75894,224.25386 0 0 1 312.13672,710.92969 224.75894,224.25386 0 0 1 536.89454,486.67773 Z m 0,41.57227 a 183.09261,182.68115 0 0 0 -183.0918,182.67969 183.09261,182.68115 0 0 0 37.25195,110.07226 l 266.25,-247.38867 A 183.09261,182.68115 0 0 0 536.89454,528.25 Z M 687.72071,607.40234 422.67383,853.67188 A 183.09261,182.68115 0 0 0 536.89454,893.61133 183.09261,182.68115 0 0 0 719.98829,710.92969 183.09261,182.68115 0 0 0 687.72071,607.40234 Z"
id="path3424"
inkscape:connector-curvature="0" />
<g
id="g4319"
transform="matrix(0.73397676,-0.47399264,0.47399264,0.73397676,-954.18931,1157.9347)">
<path
sodipodi:nodetypes="sscscsss"
inkscape:connector-curvature="0"
id="path4375"
d="m 1553.5714,420.93363 c 9.4724,-29.88909 32.5886,-50.12241 55,-69.28571 116.6944,-99.78194 210.8943,-55.73979 211.4286,129.28571 46.3223,-48.79389 77.2317,-19.18981 58.1158,32.12244 -10.5068,28.20331 -40.7796,73.82504 -65.2587,42.16328 -62.0208,162.28798 -235.737,208.55449 -267.3237,-47.83444 -1.7694,-14.36211 6.7176,-27.24112 9.825,-42.52646 3.1074,-15.28534 -6.1587,-30.1303 -1.787,-43.92482 z"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#fde4c0;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
<path
sodipodi:nodetypes="csscsssssssscccsscscc"
inkscape:connector-curvature="0"
id="path4377"
d="m 1670.7923,572.03467 c -50.5207,33.76022 -8.3119,37.60242 25.2538,54.04316 28.196,13.81062 99.2973,-30.43844 105.0559,-101.52033 3.3,-40.73397 5.4518,-103.50329 -22.7284,-126.77414 21.5796,-72.65894 -76.1354,-62.97728 -140.9163,-4.04062 -25.0183,22.76124 -83.4945,16.5469 -113.6422,-1.51522 -36.6935,-21.98388 1.1908,-66.07832 22.7284,-103.03557 22.1267,-37.96823 67.2527,-56.43278 110.1067,-66.16499 40.8909,-9.2864 83.2045,-11.80845 122.2284,3.53554 35.4133,13.92432 67.3444,39.43455 90.4087,69.70052 12.1279,15.91482 21.5079,35.58644 22.7284,55.55839 0.8196,13.41208 -8.69,25.59117 -10.6066,38.89088 -3.6028,25.0006 15.0034,56.65263 -1.5152,75.76144 -10.6707,-18.14265 -29.2988,-9.01153 -37.8808,-3.03046 3.235,15.35278 -16.5636,18.12386 -21.2131,21.2132 -3.6829,27.67231 -9.5078,56.9544 -18.1828,83.33759 -4.3151,13.12344 1.3963,28.48048 -7.071,39.39594 -116.2362,149.84241 -217.7047,69.61537 -227.7894,-7.57614 28.549,47.29288 45.9995,-5.84767 43.9416,-13.63706 -2.0717,-7.84195 -8.6487,-9.21001 -21.7183,-10.6066 18.4303,-17.61195 66.4229,-17.31534 80.8122,-3.53553 z"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:0.5;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
<path
sodipodi:nodetypes="cssc"
inkscape:connector-curvature="0"
id="path4379"
d="m 1766.5043,432.88616 c 2.215,-5.64195 -82.4917,-59.51648 -107.3287,-20.70813 -6.5923,10.30059 23.9911,8.83883 36.618,2.27284 20.7808,-10.80604 46.7181,6.58855 70.7107,18.43529 z"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#412e07;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
<path
sodipodi:nodetypes="sssss"
inkscape:connector-curvature="0"
id="path4383"
d="m 1606.3951,422.53209 c 0.9746,0.26564 3.0419,-10.7985 -0.7576,-12.6269 -13.3466,-6.42269 -33.9737,-6.37661 -46.2145,3.03045 -5.2135,4.00656 -11.5833,22.61999 -6.3135,18.68782 16.7402,-12.49106 36.5189,-13.66139 53.2856,-9.09137 z"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#412e07;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
<path
sodipodi:nodetypes="ssss"
inkscape:connector-curvature="0"
id="path4387"
d="m 1591.7479,515.21359 c 14.1075,14.22657 49.0657,3.82144 60.1041,0.50507 15.1813,-4.56107 -49.5692,-30.78806 -60.1041,-23.99112 -6.5784,4.24424 -5.5124,17.92713 0,23.48605 z"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#dbc5a8;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
<path
sodipodi:nodetypes="ccc"
inkscape:connector-curvature="0"
id="path4385"
d="m 1703.8748,575.5702 c -2.4889,-69.03002 -123.0085,-77.59424 -128.0368,-13.38452 15.3659,-35.35707 90.9439,-39.17136 128.0368,13.38452 z"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:0.54878049;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
<path
sodipodi:nodetypes="ccc"
inkscape:connector-curvature="0"
id="path4389"
d="m 1740.4928,449.0486 c -24.6033,-10.63023 -51.0204,-30.4158 -68.9429,-7.32361 26.5755,-2.18034 46.6746,3.96609 68.9429,7.32361 z"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:0.5;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
<path
sodipodi:nodetypes="ccc"
inkscape:connector-curvature="0"
id="path4391"
d="m 1569.0194,453.08921 c 13.0385,-6.5504 28.1346,-10.35723 44.1942,-12.87945 -21.763,-7.42614 -37.5676,-4.92176 -44.1942,12.87945 z"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:0.5;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
<path
id="path4393"
d="m 1692.625,430.99805 c -0.4456,-0.005 -0.8864,0.018 -1.3281,0.0332 a 8.8388348,8.2706242 0 0 0 -1.3125,4.31641 8.8388348,8.2706242 0 0 0 3.1347,6.3164 c 3.3473,0.24118 6.6228,0.57417 9.834,0.99024 a 8.8388348,8.2706242 0 0 0 4.709,-7.30664 8.8388348,8.2706242 0 0 0 -0.1152,-1.3125 c -5.1307,-1.80358 -10.1386,-2.98665 -14.9219,-3.03711 z"
style="opacity:1;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.89999998;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
inkscape:connector-curvature="0" />
<path
id="path4395"
d="m 1593.0137,436.28906 c -3.7184,0.008 -7.1081,0.56414 -10.1407,1.71485 a 8.4600277,8.1443548 0 0 0 -0.9746,3.78515 8.4600277,8.1443548 0 0 0 1.9786,5.22071 c 4.7738,-1.58078 9.7433,-2.90152 14.8437,-4.04688 a 8.4600277,8.1443548 0 0 0 0.098,-1.17383 8.4600277,8.1443548 0 0 0 -2.0743,-5.33008 c -1.2763,-0.11078 -2.522,-0.17238 -3.7304,-0.16992 z"
style="opacity:1;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.89999998;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
inkscape:connector-curvature="0" />
<path
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#412e07;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m 1778.3736,397.78336 c 21.5796,-72.65894 -76.1354,-62.97728 -140.9163,-4.04062 -25.0183,22.76124 -83.4945,16.5469 -113.6422,-1.51522 -36.6935,-21.98388 1.1908,-66.07832 22.7284,-103.03557 22.1267,-37.96823 67.2527,-56.43278 110.1067,-66.16499 40.8909,-9.2864 83.2045,-11.80845 122.2284,3.53554 35.4133,13.92432 67.3444,39.43455 90.4087,69.70052 12.1279,15.91482 21.5079,35.58644 22.7284,55.55839 0.8196,13.41208 -8.69,25.59117 -10.6066,38.89088 -3.6028,25.0006 15.0034,56.65263 -1.5152,75.76144 -10.6707,-18.14265 -29.2988,-9.01153 -37.8808,-3.03046 3.235,15.35278 -16.5636,18.12386 -21.2131,21.2132 -6.0301,-19.16512 -6.4252,-54.01108 -42.4264,-86.87311 z"
id="path3509"
inkscape:connector-curvature="0"
sodipodi:nodetypes="csssssssscccc" />
<path
sodipodi:nodetypes="ccc"
inkscape:connector-curvature="0"
id="path4313"
d="m 1586.4898,572.50642 c 0.7234,-29.83178 65.7458,-27.32174 97.4388,-6.92993 -36.3381,-4.32443 -72.3868,-8.00354 -97.4388,6.92993 z"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ea715f;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.60000002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
<path
sodipodi:nodetypes="ccc"
inkscape:connector-curvature="0"
id="path4315"
d="m 1586.0714,571.64792 c -11.3479,-50.2996 92.1132,-27.13496 97.7092,-6.61612 -21.6104,-12.90451 -91.5268,-28.56781 -97.7092,6.61612 z"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ea715f;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.60000002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
<path
sodipodi:nodetypes="cssc"
inkscape:connector-curvature="0"
id="path4317"
d="m 1841.4286,480.57649 c 0,0 45.0956,-28.29135 22.1428,27.14286 -4.4669,10.78817 -20.2915,-0.68531 -24.8214,13.21428 -2.2136,6.79224 24.1712,14.25368 -4.4643,28.57143"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:8.19999981;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.48780488;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
</g>
<path
inkscape:connector-curvature="0"
id="path4627"
d="m 422.67383,853.67188 265.04688,-246.26954 -30.41602,-33.78906 -266.25,247.38867 z"
style="opacity:1;fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:8.19999981;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
sodipodi:nodetypes="ccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 17 KiB

View file

@ -55,13 +55,6 @@ describe Order do
expect(@order).to_not be_valid
end
end
describe 'products' do
it 'should be present' do
@order.products.clear
expect(@order).to_not be_valid
end
end
end
###############

View file

@ -19,6 +19,8 @@
# private :boolean default("f")
#
require 'webmock/rspec'
describe User do
before :each do
@user = create :user
@ -52,10 +54,65 @@ describe User do
end
end
describe 'balance' do
before :all do
@api_url = "www.example.com/api.json"
end
it 'should be nil if offline' do
stub_request(:get, /.*/).to_return(status: 404)
expect(@user.balance).to be nil
end
it 'should be updated when online' do
balance = 5
stub_request(:get, /.*/).to_return(status: 200, body: JSON.dump({ balance: balance }))
expect(@user.balance).to eq balance
end
end
end
describe 'omniauth' do
it 'should be a new user' do
name = "yet-another-test-user"
omniauth = double(uid: name)
expect(User.from_omniauth(omniauth).name).to eq name
end
it 'should be the logged in user' do
second_user = create :user
omniauth = double(uid: second_user.name)
expect(User.from_omniauth(omniauth)).to eq second_user
end
end
describe 'static users' do
describe 'koelkast' do
it 'should be false by default' do
expect(@user.reload.koelkast).to be false
end
it 'should be true for koelkast' do
expect(User.koelkast.koelkast).to be true
end
it 'should not be an admin' do
expect(User.koelkast.admin).to be false
end
end
describe 'guest' do
it 'should not be an admin' do
expect(User.guest.admin).to be false
end
it 'should be public' do
expect(User.guest.private).to be false
end
it 'should be a guest' do
expect(User.guest.guest?).to be true
end
end
end