trollo 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53,6 +53,11 @@ class CreateTrolloTables < ActiveRecord::Migration
53
53
  t.references :list
54
54
  end
55
55
 
56
+ create_table :trollo_cards_labels do |t|
57
+ t.references :card
58
+ t.references :label
59
+ end
60
+
56
61
  add_index :trollo_lists, [:trollable_type, :trollable_id]
57
62
 
58
63
  add_index :trollo_cards, :list_id
data/lib/trollo/card.rb CHANGED
@@ -6,6 +6,7 @@ module Trollo
6
6
 
7
7
  belongs_to :list, touch: true
8
8
  has_many :tasklists, order: :ordinal, dependent: :destroy
9
+ has_and_belongs_to_many :labels, join_table: 'trollo_cards_labels'
9
10
  before_save :set_ordinal
10
11
  attr_accessible :name, :description, :workflow_state, :trollable
11
12
 
@@ -23,7 +24,11 @@ module Trollo
23
24
  end
24
25
 
25
26
  def set_ordinal
26
- self.ordinal ||= list.cards.length + 1
27
+ self.ordinal ||= if list
28
+ list.cards.length + 1
29
+ else
30
+ 1
31
+ end
27
32
  end
28
33
 
29
34
  def check
data/lib/trollo/label.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  module Trollo
2
2
 
3
3
  class Label < ActiveRecord::Base
4
- has_and_belongs_to_many :cards, join_table: 'trollo_labels_lists'
4
+ has_and_belongs_to_many :lists, join_table: 'trollo_labels_lists'
5
+ has_and_belongs_to_many :cards, join_table: 'trollo_cards_labels'
5
6
  attr_accessible :name
6
7
  end
7
8
 
@@ -1,3 +1,3 @@
1
1
  module Trollo
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -52,6 +52,11 @@ ActiveRecord::Schema.define do
52
52
  t.references :list
53
53
  end
54
54
 
55
+ create_table :trollo_cards_labels do |t|
56
+ t.references :card
57
+ t.references :label
58
+ end
59
+
55
60
  add_index :trollo_lists, [:trollable_type, :trollable_id]
56
61
 
57
62
  add_index :trollo_cards, :list_id
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Trollo::Card do
4
+
5
+ it "should support labels" do
6
+ card = Trollo::Card.create!
7
+ label = Trollo::Label.create! name: 'Bug'
8
+
9
+ card.labels << label
10
+ card.labels.map(&:name).should == ['Bug']
11
+ end
12
+
13
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trollo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -138,6 +138,7 @@ files:
138
138
  - spec/internal/db/schema.rb
139
139
  - spec/internal/log/.gitignore
140
140
  - spec/internal/public/favicon.ico
141
+ - spec/lib/trollo/card_spec.rb
141
142
  - spec/lib/trollo/list_spec.rb
142
143
  - spec/lib/trollo/task_spec.rb
143
144
  - spec/spec_helper.rb
@@ -173,6 +174,7 @@ test_files:
173
174
  - spec/internal/db/schema.rb
174
175
  - spec/internal/log/.gitignore
175
176
  - spec/internal/public/favicon.ico
177
+ - spec/lib/trollo/card_spec.rb
176
178
  - spec/lib/trollo/list_spec.rb
177
179
  - spec/lib/trollo/task_spec.rb
178
180
  - spec/spec_helper.rb