From 363055997ea801c751e154229f47aba3f987ec4c Mon Sep 17 00:00:00 2001 From: pqauvsum Date: Sat, 13 Sep 2014 22:52:40 +0200 Subject: [PATCH] added pagination gem, many fixes - BUGFIX: improved :dividend filter, droped hardwired limit - smr_humanize helper for humanizing all sorts of numbers - integration test for Blog and Figures - PATCH: merged pagination - BUGFIX: figures row merge result must be carried into next loop, else its lost - fixed user test about working with documents --- gui/Gemfile | 4 +- .../controllers/objects/figurevar_controller.rb | 4 +- .../controllers/objects/portfolio_controller.rb | 4 +- gui/app/controllers/objects/stock_controller.rb | 2 +- gui/app/helpers/application_helper.rb | 48 ++++++++++++++++-- gui/app/views/assets/index.html.erb | 18 +++---- gui/app/views/cashflow/index.html.erb | 6 +-- gui/app/views/documents/index.html.erb | 11 ++-- gui/app/views/objects/figurevar/index.html.erb | 3 +- gui/app/views/objects/portfolio/index.html.erb | 4 +- gui/app/views/objects/stock/index.html.erb | 4 +- gui/app/views/positions/show.html.erb | 44 ++++++++-------- gui/app/views/quoterecords/index.html.erb | 19 +++---- gui/config/locales/en.yml | 7 ++- gui/lib/smr_asset.rb | 1 + gui/lib/smr_cashflowlog.rb | 4 +- gui/lib/smr_document.rb | 15 ++++-- gui/lib/smr_figures.rb | 6 ++- gui/lib/smr_quoterecords.rb | 6 +++ gui/public/stylesheets/all.css | 9 ++++ gui/test/fixtures/figure_data.yml | 55 ++++++++++++++++++++ gui/test/fixtures/figure_var.yml | 21 ++++++++ gui/test/integration/demo1_user_session_test.rb | 59 ++++++++++++++++++++++ 23 files changed, 287 insertions(+), 67 deletions(-) diff --git a/gui/Gemfile b/gui/Gemfile index 74a0a4a..661bc7c 100644 --- a/gui/Gemfile +++ b/gui/Gemfile @@ -10,5 +10,5 @@ gem 'thin' # better than the webrick HTTP server! gem 'bcrypt-ruby', '~> 3.1.2' # staff used in helpers, mainly for formatting -gem 'percentage', '~> 1.0.0' # http://github.com/timcraft/percentage - +gem 'percentage', '~> 1.0.0' # https://github.com/timcraft/percentage +gem 'paginate', '~> 3.0' # http://rubygems.org/gems/paginate diff --git a/gui/app/controllers/objects/figurevar_controller.rb b/gui/app/controllers/objects/figurevar_controller.rb index 588f651..0ac2e78 100644 --- a/gui/app/controllers/objects/figurevar_controller.rb +++ b/gui/app/controllers/objects/figurevar_controller.rb @@ -19,7 +19,9 @@ class Objects::FigurevarController < ObjectsController def index super - @figurevars = FigureVar.where(:id_user=>[0,current_user.id]).order(:name) + @figurevars = FigureVar.where(:id_user=>[0,current_user.id]) + .order(:name) + .paginate(:page => params[:page]) @figurevar = FigureVar.new end diff --git a/gui/app/controllers/objects/portfolio_controller.rb b/gui/app/controllers/objects/portfolio_controller.rb index fbf5909..1749229 100644 --- a/gui/app/controllers/objects/portfolio_controller.rb +++ b/gui/app/controllers/objects/portfolio_controller.rb @@ -19,7 +19,9 @@ class Objects::PortfolioController < ObjectsController def index super - @portfolios = Portfolio.where(:id_user=>current_user.id).order(:name) + @portfolios = Portfolio.where(:id_user=>current_user.id) + .order(:name) + .paginate(:page => params[:page]) @portfolio = Portfolio.new(:date_created => Time.now.to_i) end diff --git a/gui/app/controllers/objects/stock_controller.rb b/gui/app/controllers/objects/stock_controller.rb index b0e5f51..7be87db 100644 --- a/gui/app/controllers/objects/stock_controller.rb +++ b/gui/app/controllers/objects/stock_controller.rb @@ -26,7 +26,7 @@ class Objects::StockController < ObjectsController def index super - @stocks = Stock.order(:name) + @stocks = Stock.order(:name).paginate(:page => params[:page]) @stock = Stock.new @symbolextensions = StockSymbolextension.all diff --git a/gui/app/helpers/application_helper.rb b/gui/app/helpers/application_helper.rb index 91738ef..4f10e7f 100644 --- a/gui/app/helpers/application_helper.rb +++ b/gui/app/helpers/application_helper.rb @@ -27,20 +27,60 @@ module ApplicationHelper end ## - # Returns change from +val1+ to +val2+ in percent. + # Returns change from +val1+ to +val2+ in percent, as smr_humanize()d String. def percentage_change(val1, val2) return nil if val1.zero? or val2.blank? - Percentage.change(val1, val2) + smr_humanize(Percentage.change(val1, val2)) end ## - # Returns percentage of +val+ from +base+. + # Returns percentage of +val+ from +base+, as smr_humanize()d String. def percentage_of(base, val) if base.zero? then return nil end - BigDecimal(val.to_s).as_percentage_of(base) + smr_humanize(BigDecimal(val.to_s).as_percentage_of(base)) end ## + # humanize a number in ways useful in SMR + def smr_humanize(n) + unit = String.new + format = '%s' + skip_rounding=false + + # decide whether to round + skip_rounding = true if n.is_a?(Fixnum) + skip_rounding = true if (n.nil? or n == false) + + if n.is_a?(Percentage) + unit = '%' + format = if n.to_f < 10 then '%.1f' else '%i' end + skip_rounding = true + end + + if n.is_a?(Time) + format = '%s'+n.strftime('%Y-%m-%d') + n = nil + skip_rounding = true + end + + # do generic rounding if necessary + unless skip_rounding + case n + when 0..1 then format = '%.4f' + when 1..9 then format = '%.3f' + when 10..99 then format = '%.2f' + when 100..1000 then format = '%.1f' + else + format = '%i' + end + end + + # return a String + (format + '%s') % [n, unit] + end + + + ## # Returns menu to browse SMR functionality in HTML format, see # @smr_menu_items and smr_menu_addsubitem(). # TODO: supports one sublevel only, do we ever need more? diff --git a/gui/app/views/assets/index.html.erb b/gui/app/views/assets/index.html.erb index 13d5c8f..7fba43f 100644 --- a/gui/app/views/assets/index.html.erb +++ b/gui/app/views/assets/index.html.erb @@ -14,16 +14,16 @@ <%= f.number_field :volume, :placeholder=>'Volume Traded', :step=>1 %>
<%= f.text_field :exchange, :placeholder=>'Exchange' %>

- <%= f.submit 'Save Payment Received' %> + <%= f.submit 'Save Quotation' %> <% end %> <% end %>

Open Positions

@@ -43,11 +43,11 @@ <% @open_positions.each do |p| %> <%= link_to "+", controller: 'positions', action: 'show', id: p.id %><%=p.stock.name%> - <%= p.shares %> - <%= p.cost_price %> - <%= p.last_quote %> - <%= p.market_value %> - <%= p.profit_loss %> <%= percentage_change(p.invested, p.market_value) %> + <%= smr_humanize(p.shares) %> + <%= smr_humanize(p.cost_price) %> + <%= smr_humanize(p.last_quote) %> + <%= smr_humanize(p.market_value) %> + <%= smr_humanize(p.profit_loss) %> <%= percentage_change(p.invested, p.market_value) %> <%= percentage_of(@assets.market_value, p.market_value) %> <% if not p.comment.empty? %> diff --git a/gui/app/views/cashflow/index.html.erb b/gui/app/views/cashflow/index.html.erb index d05e9d2..05c3429 100644 --- a/gui/app/views/cashflow/index.html.erb +++ b/gui/app/views/cashflow/index.html.erb @@ -25,7 +25,7 @@ <% end %> <% if not @log.empty? %> -

Total Cashflow in Report: <%= @log.total %>

+

Total Cashflow in Report: <%= smr_humanize(@log.total) %>

Log

@@ -35,9 +35,9 @@ <% @log.each do |item| %> - + - + <% end %> diff --git a/gui/app/views/documents/index.html.erb b/gui/app/views/documents/index.html.erb index 95fba6c..a7edfae 100644 --- a/gui/app/views/documents/index.html.erb +++ b/gui/app/views/documents/index.html.erb @@ -14,17 +14,22 @@
<%= item.date %><%= smr_humanize(item.date) %> <%= item.what %> <%= item.comment %><%= item.total %><%= smr_humanize(item.total) %>
- + + + + + + <% @documents.each do |d| %> - + + - <% end %> diff --git a/gui/app/views/objects/figurevar/index.html.erb b/gui/app/views/objects/figurevar/index.html.erb index a675758..e8d8ec4 100644 --- a/gui/app/views/objects/figurevar/index.html.erb +++ b/gui/app/views/objects/figurevar/index.html.erb @@ -22,10 +22,11 @@ <% if not @figurevars %>

No figures exist yet.

<% else %> +
UploadedFilenameComment / Relations
<%= paginate @documents %>UploadedFilenameComment / Relations
<%= d.time_upload %><%= link_to 'delete', controller: 'documents', action: 'delete_document', id: d.id if d.time_upload > 5.days.ago %><%= smr_humanize d.time_upload %> <%= link_to d.filename, :id=>d.id, :action=>'download' %><%= number_to_human_size(d.size, :precision=>2) %> <%= d.comment %> <%= d.relations_text %> <%= link_to 'delete', controller: 'documents', action: 'delete_document', id: d.id if d.time_upload > 5.days.ago %>
- + diff --git a/gui/app/views/objects/portfolio/index.html.erb b/gui/app/views/objects/portfolio/index.html.erb index 080e551..07309d8 100644 --- a/gui/app/views/objects/portfolio/index.html.erb +++ b/gui/app/views/objects/portfolio/index.html.erb @@ -23,10 +23,12 @@ <% if not @portfolios %>

No securities exist yet.

<% else %> + +
<%= paginate @figurevars %> Unit Expression
- + diff --git a/gui/app/views/objects/stock/index.html.erb b/gui/app/views/objects/stock/index.html.erb index d6d1aff..38b035a 100644 --- a/gui/app/views/objects/stock/index.html.erb +++ b/gui/app/views/objects/stock/index.html.erb @@ -26,10 +26,12 @@ <% if not @stocks %>

No securities exist yet.

<% else %> + +
<%= paginate @portfolios %> Created Tax Allowance
- + diff --git a/gui/app/views/positions/show.html.erb b/gui/app/views/positions/show.html.erb index 7b9a2b3..635482d 100644 --- a/gui/app/views/positions/show.html.erb +++ b/gui/app/views/positions/show.html.erb @@ -20,18 +20,18 @@

Position has been settled on <%= @position.time_closed %>.

<%= paginate @stocks %> Symbol Quote Source Fetch Quote
- - - - - - + + + + + +
Purchased Volume<%=@position.purchase_volume%>
Settled Volume<%=@position.settled_volume%>
= Profit/Loss<%=@position.profit_loss%> <%= percentage_change(@position.purchase_volume, @position.settled_volume)%>
Dividend<%=@position.dividend.received%>
Charges<%=@position.charges%>
= Gain<%=@position.gain%> <%= percentage_of(@position.purchase_volume, @position.gain) %>
Purchased Volume<%= smr_humanize(@position.purchase_volume) %>
Settled Volume<%= smr_humanize(@position.settled_volume) %>
= Profit/Loss<%= smr_humanize(@position.profit_loss) %> <%= percentage_change(@position.purchase_volume, @position.settled_volume)%>
Dividend<%= smr_humanize(@position.dividend.received) %>
Charges<%= smr_humanize(@position.charges) %>
= Gain<%= smr_humanize(@position.gain) %> <%= percentage_of(@position.purchase_volume, @position.gain) %>
<% elsif @position.is_new? %>

This position is new. You may order something or just close it.

<% else %>

- Position <% if @position.shares<0 %> is short by <% else %> holds <% end %> <%= @position.shares %> shares + Position <% if @position.shares<0 %> is short by <% else %> holds <% end %> <%= smr_humanize(@position.shares) %> shares which are valued at <%= @position.last_quote %> a share. <% if @position.is_closed? %> @@ -40,12 +40,12 @@

- - - - - - + + + + + +
Invested Money<%=@position.invested%>
Market Value<%=@position.market_value%>
= Profit/Loss<%=@position.profit_loss%> <%= percentage_change(@position.invested, @position.market_value)%>
Dividend<%=@position.dividend.received%>
Charges<%=@position.charges%>
= Gain<%=@position.gain%> <%= percentage_change(@position.invested, @position.dirty_value) %>
Invested Money<%= smr_humanize(@position.invested) %>
Market Value<%= smr_humanize(@position.market_value) %>
= Profit/Loss<%= smr_humanize(@position.profit_loss) %> <%= percentage_change(@position.invested, @position.market_value)%>
Dividend<%= smr_humanize(@position.dividend.received) %>
Charges<%= smr_humanize(@position.charges) %>
= Gain<%= smr_humanize(@position.gain) %> <%= percentage_change(@position.invested, @position.dirty_value) %>
<% end %> @@ -67,7 +67,7 @@ #<%= o.id %> <%=o.exchange%> <%=o.time_issued%> / <%=o.time_expire%> - <%=o.type%> <%=o.shares%> shares at <%=o.limit%> + <%=o.type%> <%= smr_humanize(o.shares) %> shares at <%=o.limit%> <%= label_tag 'execute_quote', 'execute at quote:' %> <%= form_tag(controller: 'positions', action: 'execute_order', method: "post") do %> @@ -104,12 +104,12 @@ #<%= pr.id_order %> <% if not pr.Order.exchange.nil? %><%=pr.Order.exchange%> via <% end %><%=@position.portfolio.name%> - <%=pr.time%> - <%=pr.Order.type%> <%=pr.Order.shares%> shares at <%=pr.Order.quote%> + <%=smr_humanize(pr.time) %> + <%=pr.Order.type%> <%=smr_humanize(pr.Order.shares)%> shares at <%=pr.Order.quote%> <%=pr.Order.status%> - <%=revision_volume(pr.Order.shares, pr.Order.quote)%> - <%=pr.shares%> - <%=revision_profitloss(@position.last_quote, pr.Order.shares, pr.Order.quote) %> + <%=smr_humanize(revision_volume(pr.Order.shares, pr.Order.quote)) %> + <%=smr_humanize(pr.shares) %> + <%=smr_humanize(revision_profitloss(@position.last_quote, pr.Order.shares, pr.Order.quote)) %> <% end %> @@ -129,9 +129,9 @@ <% @position.dividend.payments.reverse.each do |d| %> - <%= d[:time] %> - <%= d[:received] %> on <%= d[:shares] %> shares - <%= d[:total] %> + <%= smr_humanize(d[:time]) %> + <%= smr_humanize(d[:received]) %> on <%= smr_humanize(d[:shares]) %> shares + <%= smr_humanize(d[:total]) %> <% end %> diff --git a/gui/app/views/quoterecords/index.html.erb b/gui/app/views/quoterecords/index.html.erb index add9834..573d113 100644 --- a/gui/app/views/quoterecords/index.html.erb +++ b/gui/app/views/quoterecords/index.html.erb @@ -12,8 +12,6 @@ <% if not @intraday_quotes.empty? %>

Observations intraday quotes in contrast to previous records

-

- <% @intraday_quotes.each do |q| %> @@ -38,16 +36,15 @@ <% end %>
-

<% end %> <% if not @quoterecords.empty? %> -

Previous Records

+ - + <% @quoterecords.get_columns.each do |c| %> <% end %> @@ -62,7 +59,7 @@ <% @quoterecords.each do |qr| %> - + <% @quoterecords.get_columns.each do |c| %> <% end %> @@ -70,17 +67,17 @@ <% end %>
<%= paginate @quoterecords %><%= @quoterecords.translate_column(c) %>
<%= link_to qr.time_created %><%= qr.comment %><%=link_to '+', qr %> <%=smr_humanize(qr.time_created)%> <%= qr.comment %><%= qr.Quote.quote if qr.is_column?(c) %>
-

<% end %>

Sensitivity Settings

-

<%= form_for @sensitivity, :url=>{controller: :quoterecord_threshold, action: :create}, :method=>:POST do |f| %> +

+ adjust when UP/DOWN or Pivot Point hits are triggered <%= hidden_field_tag :id, @sensitivity.id %> <%= f.hidden_field :id_stock %> - <%= f.number_field :quote_sensitivity, :step=>0.1, :min=>0.1 %> - <%= f.number_field :hit_sensitivity, :step=>0.1, :min=>0.1 %> + <%= f.number_field :quote_sensitivity, :step=>0.1, :min=>0.1, :placeholder=>'UP/DOWN hit sensitivity' %> + <%= f.number_field :hit_sensitivity, :step=>0.1, :min=>0.1, :placeholder=>'Pivot Point hit sensitivity' %> <%= f.submit 'save' %> +
<% end %> -

diff --git a/gui/config/locales/en.yml b/gui/config/locales/en.yml index a747bfa..61aeaad 100644 --- a/gui/config/locales/en.yml +++ b/gui/config/locales/en.yml @@ -2,4 +2,9 @@ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. en: - hello: "Hello world" + paginate: + next: '»' + previous: '«' + page: "%{page}" + more: '...' + diff --git a/gui/lib/smr_asset.rb b/gui/lib/smr_asset.rb index 64bccec..5d4435d 100644 --- a/gui/lib/smr_asset.rb +++ b/gui/lib/smr_asset.rb @@ -75,6 +75,7 @@ class SmrAsset AND (p.closed=0 OR p.closed>%i) AND pr.date=LASTDATE AND pr.id_position=LASTPOSITION + AND po.name NOT LIKE "watchlist:%%" /* HACK for speed on old DBs */ ORDER BY s.name, pr.date' % [@date, @id_user, @date]).get_all # turn Position objects into SmrPosition diff --git a/gui/lib/smr_cashflowlog.rb b/gui/lib/smr_cashflowlog.rb index 2339bd0..9f432b2 100644 --- a/gui/lib/smr_cashflowlog.rb +++ b/gui/lib/smr_cashflowlog.rb @@ -96,7 +96,6 @@ class SmrCashflowLog .joins('LEFT JOIN position p ON p.id = order.id_position') .joins('LEFT JOIN stock s ON s.id = p.id_stock') .order(issued: :desc) - .limit(10) orders.each do |o| case @filter @@ -137,11 +136,12 @@ class SmrCashflowLog Position.select(:id) .joins(:Portfolio) .where('portfolio.id_user'=>@id_user) - .where('position.closed=0 OR position.closed>=%i' % @end_date).each do |p| + .where('(position.closed=0 OR position.closed>=%i) OR (position.closed BETWEEN %i AND %i)' % [@end_date, @start_date, @end_date]).each do |p| smrp = SmrPosition.new(p.id, @id_user, Time.at(@end_date)) smrp.dividend.payments.each do |dp| next if dp[:time].to_i < @start_date + next if dp[:total] == 0.0 # skips positions sold right before ex-Div date log_dividends << SmrCashflowLogItem.new(dp[:time], 'received dividend of %.2f for %i shares from %s' % [dp[:received], dp[:shares], smrp.stock.name], dp[:total], diff --git a/gui/lib/smr_document.rb b/gui/lib/smr_document.rb index 8e35172..a2cf398 100644 --- a/gui/lib/smr_document.rb +++ b/gui/lib/smr_document.rb @@ -13,8 +13,10 @@ # You should have received a copy of the GNU General Public License along with # SMR. If not, see . # -# -# A document with relations to Portfolio, Position, Order and/or Stock. + + +## +# A Document with relations to Portfolio, Position, Order and/or Stock. # # == Security # For the sake of security its required to supply id of User that is used to @@ -22,6 +24,7 @@ # parameter should not come from user input, but rather result from a # successful authentication process. # + # == Attention # - right now this is only for viewing perposes # - to store new data records use the model classes directly. These are @@ -171,7 +174,13 @@ class SmrDocuments def each(&block) @smr_documents.each(&block) end - + + ## + # returns number of SmrDocument items collected + def size + @smr_documents.size + end + ## # returns number of SmrDocument objects available def count diff --git a/gui/lib/smr_figures.rb b/gui/lib/smr_figures.rb index 041f6cd..368ae93 100644 --- a/gui/lib/smr_figures.rb +++ b/gui/lib/smr_figures.rb @@ -233,9 +233,13 @@ class SmrFiguresDataTable < SmrFiguresDataMap if row[0]==prev_row[0] and row[1]==prev_row[1] then # merge into prev_row since row is more recent, see sort_by above @table[k] = prev_row.merge(row) +#p "==> %s" % prev_row +#p "==+ %s" % row +#p "=== %s" % @table[k] +#p "____" @table.delete(prev_key) if k > prev_key end - prev_row = row + prev_row = @table[k] prev_key = k end diff --git a/gui/lib/smr_quoterecords.rb b/gui/lib/smr_quoterecords.rb index 51c4ea3..0bee77e 100644 --- a/gui/lib/smr_quoterecords.rb +++ b/gui/lib/smr_quoterecords.rb @@ -39,6 +39,12 @@ class SmrQuoterecords end ## + # returns number of Quoterecord objects held in the collection + def size + @quoterecords.size + end + + ## # return column names def get_columns Quoterecord.new.get_columns diff --git a/gui/public/stylesheets/all.css b/gui/public/stylesheets/all.css index 30f76cc..19d297b 100644 --- a/gui/public/stylesheets/all.css +++ b/gui/public/stylesheets/all.css @@ -12,3 +12,12 @@ table { margin-left:auto; margin-right:auto; } + +// pagination +.paginate { overflow: hidden; } +.paginate li { + float: left; + padding: 0 0 0.5em 0.5em; + list-style-type: none; +} +.paginate .disabled { display: none; } diff --git a/gui/test/fixtures/figure_data.yml b/gui/test/fixtures/figure_data.yml index 1694ec9..3d00193 100644 --- a/gui/test/fixtures/figure_data.yml +++ b/gui/test/fixtures/figure_data.yml @@ -76,3 +76,58 @@ figure_data_007: is_expected: is_audited: comment: My, that weawwy was a dewicious weg of wamb. +figure_data_008: + id: 8 + id_figure_var: 1 + id_stock: 3 + date: 1410559200 + period: q2 + analyst: ste + value: 4.0 + is_expected: 0 + is_audited: 0 + comment: Elmer Fudds numbers are flaky. +figure_data_009: + id: 9 + id_figure_var: 1 + id_stock: 3 + date: 1410559200 + period: q1 + analyst: ste + value: 2.0 + is_expected: 0 + is_audited: 0 + comment: '' +figure_data_010: + id: 10 + id_figure_var: 1 + id_stock: 3 + date: 1410559200 + period: year + analyst: ste + value: 8.0 + is_expected: 1 + is_audited: 0 + comment: '' +figure_data_011: + id: 11 + id_figure_var: 4 + id_stock: 25 + date: 1410559200 + period: q1 + analyst: '3' + value: 3.0 + is_expected: 0 + is_audited: 0 + comment: '' +figure_data_012: + id: 12 + id_figure_var: 4 + id_stock: 25 + date: 1379023200 + period: q1 + analyst: '' + value: 4.0 + is_expected: 0 + is_audited: 0 + comment: '' diff --git a/gui/test/fixtures/figure_var.yml b/gui/test/fixtures/figure_var.yml index 51e3ca5..ea62a6d 100644 --- a/gui/test/fixtures/figure_var.yml +++ b/gui/test/fixtures/figure_var.yml @@ -13,3 +13,24 @@ figure_var_002: unit: expression: comment: regular var, no autofigure, added after FirstVar +figure_var_003: + id: 3 + id_user: 0 + name: AutoVar1 + unit: kg + expression: this * that % 2 *3.14 + comment: '' +figure_var_004: + id: 4 + id_user: 2 + name: Demo1Var1 + unit: f + expression: '' + comment: first var of demo1 user +figure_var_005: + id: 5 + id_user: 2 + name: Demo1Var2 + unit: '' + expression: '' + comment: second var of demo1 user diff --git a/gui/test/integration/demo1_user_session_test.rb b/gui/test/integration/demo1_user_session_test.rb index 9988485..da448d7 100644 --- a/gui/test/integration/demo1_user_session_test.rb +++ b/gui/test/integration/demo1_user_session_test.rb @@ -206,4 +206,63 @@ class Demo1UserSessionTest < ActionDispatch::IntegrationTest assert i.is_a?(SmrCashflowLogItem) end end + + ## + # view and add FigureData + test "work with figure data" do + smr_login(LOGIN, PASSWORD) + + get figures_path + assert_response :success + assert_equal figures_path, path + assert_not_nil sec = assigns(:securities) + assert sec.is_a?(ActiveRecord::Relation) + assert_not_nil sec_selected = assigns(:selected_security) + assert sec_selected.is_a?(Stock) + assert_not_nil have_data = assigns(:have_data) + assert have_data.is_a?(FalseClass) + + # select a security that has figure data + get figures_path, {:id_stock=>25, :show=>'this'} + assert_response :success + assert assigns(:have_data).is_a?(TrueClass) + assert assigns(:datatable).render # Raises if no data + + # add new FigureData + # FIXME: tbd + end + + ## + # use the personal blog + test "read and blog articles" do + smr_login(LOGIN, PASSWORD) + + get blog_path + assert_response :success + assert_equal blog_path, path + assert_not_nil blog = assigns(:blogroll) + assert blog.is_a?(SmrBlog) + assert blog.empty? + + # blog new article + get new_blog_path + assert_response :success + assert_equal new_blog_path, path + assert_not_nil article = assigns(:article) + assert article.is_a?(Comment) + post blog_path, + {:action=>'create', :comment=>{:title=>'IntegrationTest Title', :comment=>'IntegrationTest Text'} }, + {:referer=>blog_path } + follow_redirect! + assert_equal blog_path, path + assert_not_nil blog = assigns(:blogroll) + assert blog.is_a?(SmrBlog) + assert_not blog.empty? + item = blog.each.first + assert item.is_a?(SmrBlogItem) + assert_equal 'Comment', item.type + assert_equal 'IntegrationTest Title', item.title + assert_equal 'IntegrationTest Text', item.body + end end + -- 2.11.4.GIT