Skip to content

Commit

Permalink
Merge pull request #243 from ryanfox1985/development
Browse files Browse the repository at this point in the history
Add some things
  • Loading branch information
leikind committed Jul 17, 2015
2 parents ea4ad4e + bfb1697 commit 3fb6f0f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Coverage Status](https://coveralls.io/repos/leikind/wice_grid/badge.svg?branch=development&service=github)](https://coveralls.io/github/leikind/wice_grid?branch=development)
[![Code Climate](https://codeclimate.com/github/leikind/wice_grid/badges/gpa.svg)](https://codeclimate.com/github/leikind/wice_grid)
[![Inline docs](http://inch-ci.org/github/leikind/wice_grid.svg?branch=development)](http://inch-ci.org/github/leikind/wice_grid)
[![Security](https://hakiri.io/github/leikind/wice_grid/development.svg)](https://hakiri.io/github/leikind/wice_grid/development)
[![License](http://img.shields.io/badge/license-MIT-yellowgreen.svg)](#license)

* Yuri Leikind, yuri.leikind at gmail dot com
Expand Down
6 changes: 5 additions & 1 deletion lib/wice/table_column_matrix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ def get_column_by_model_class_and_column_name(model_class, column_name) #:nodoc
end

def get_column_in_default_model_class_by_column_name(column_name) #:nodoc:
fail WiceGridException.new('Cannot search for a column in a default model as the default model is not set') if @default_model_class.nil?
if @default_model_class.nil?
fail WiceGridException.new("Cannot search for this column(#{column_name}) in a default model(#{@default_model_class}) as the default model is not set")
end

self[@default_model_class][column_name]
end

Expand All @@ -44,6 +47,7 @@ def init_columns_of_table(model) #:nodoc:
@by_table_names[model.table_name] = self[model]
self[model].each_value { |c| c.model = model }
end

alias_method :<<, :init_columns_of_table
end
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
require 'support/active_record'
require 'action_controller'
require 'action_view'
require 'csv'
rescue LoadError
end

Expand Down
15 changes: 15 additions & 0 deletions spec/wice/lib/table_column_matrix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ module Wice
it 'should set default_model_class' do
table = TableColumnMatrix.new
table.default_model_class = Dummy

expect(table.class).to eq(TableColumnMatrix)
end

it 'should get column' do
table = TableColumnMatrix.new
table.default_model_class = Dummy

expect(Dummy.columns).to include(table.get_column_by_model_class_and_column_name(Dummy, :name))
expect(Dummy.columns).to include(table.get_column_in_default_model_class_by_column_name(:name))
end

it 'should get column not initialized' do
table = TableColumnMatrix.new
expect {table.get_column_in_default_model_class_by_column_name(:name) }.to raise_error
end
end
end
15 changes: 15 additions & 0 deletions spec/wice/lib/wice_grid_spreadsheet_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# encoding: utf-8
module Wice
describe Spreadsheet do
it 'should initialize' do
spread = Spreadsheet.new('hello', ';')

expect(spread.class).to eq(Wice::Spreadsheet)
end

it 'should add_row' do
spread = Spreadsheet.new('hello', ';')
spread << ["hello", "world!"]
end
end
end

0 comments on commit 3fb6f0f

Please sign in to comment.