update with changes from Production branch

This commit is contained in:
Lee Lawlor
2014-02-17 12:05:39 -05:00
parent 5b640cf9d8
commit a4937fb2e5
384 changed files with 14690 additions and 2242 deletions

View File

@ -1,24 +1,23 @@
require 'spec_helper'
describe ApiKey do
pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: api_keys
#
# id :integer(4) not null, primary key
# id :integer not null, primary key
# api_key :string(16)
# channel_id :integer(4)
# user_id :integer(4)
# write_flag :boolean(1) default(FALSE)
# channel_id :integer
# user_id :integer
# write_flag :boolean default(FALSE)
# created_at :datetime
# updated_at :datetime
# note :string(255)
#
require 'spec_helper'
describe ApiKey do
end

127
spec/models/channel_spec.rb Normal file
View File

@ -0,0 +1,127 @@
# encoding: UTF-8
# == Schema Information
#
# Table name: channels
#
# id :integer not null, primary key
# user_id :integer
# name :string(255)
# description :string(255)
# latitude :decimal(15, 10)
# longitude :decimal(15, 10)
# field1 :string(255)
# field2 :string(255)
# field3 :string(255)
# field4 :string(255)
# field5 :string(255)
# field6 :string(255)
# field7 :string(255)
# field8 :string(255)
# scale1 :integer
# scale2 :integer
# scale3 :integer
# scale4 :integer
# scale5 :integer
# scale6 :integer
# scale7 :integer
# scale8 :integer
# created_at :datetime
# updated_at :datetime
# elevation :string(255)
# last_entry_id :integer
# public_flag :boolean default(FALSE)
# options1 :string(255)
# options2 :string(255)
# options3 :string(255)
# options4 :string(255)
# options5 :string(255)
# options6 :string(255)
# options7 :string(255)
# options8 :string(255)
# social :boolean default(FALSE)
# slug :string(255)
# status :string(255)
# url :string(255)
# video_id :string(255)
# video_type :string(255)
# clearing :boolean default(FALSE), not null
# ranking :integer
#
require 'spec_helper'
describe Channel do
it "should be valid" do
channel = Channel.new
channel.should be_valid
end
it "should accept utf8" do
channel = Channel.create(:name => "ǎ")
channel.reload
channel.name.should == "ǎ"
end
it "should have no plugins when created" do
channel = Channel.create
channel.set_windows
channel.save
channel.name.should == "Channel #{channel.id}"
channel.windows.size.should == 2
end
it "should have video iframe after updated" do
channel = Channel.create!
video_id = "xxxxxx"
channel.assign_attributes({:video_id => video_id, :video_type => "youtube"})
channel.set_windows
channel.save
window = channel.windows.where({:wtype => :video })
window[0].html.should == "<iframe class=\"youtube-player\" type=\"text/html\" width=\"452\" height=\"260\" src=\"https://www.youtube.com/embed/xxxxxx?wmode=transparent\" frameborder=\"0\" wmode=\"Opaque\" ></iframe>"
end
it "should have private windows" do
channel = Channel.create!
channel.assign_attributes({:field1 => "Test"})
channel.set_windows
channel.save
showFlag = true
channel.private_windows(showFlag).count.should == 2 #2 private windows - 1 field and 1 status
end
# this is necessary so that the existing API is not broken
# https://thingspeak.com/channels/9/feed.json?results=10 should have 'channel' as the first key
it "should include root in json by default" do
channel = Channel.create
channel.as_json.keys.include?('channel').should be_true
end
it "should not include root using public_options" do
channel = Channel.create
channel.as_json(Channel.public_options).keys.include?('channel').should be_false
end
describe 'testing scopes' do
before :each do
@public_channel = FactoryGirl.create(:channel, :public_flag => true, :last_entry_id => 10)
@private_channel = FactoryGirl.create(:channel, :public_flag => false, :last_entry_id => 10)
end
it 'should show public channels' do
channels = Channel.public_viewable
channels.count.should == 1
end
it 'should show active channels' do
channels = Channel.active
channels.count.should == 2
end
it 'should show selected channels' do
channels = Channel.by_array([@public_channel.id, @private_channel.id])
channels.count.should == 2
end
it 'should show tagged channels' do
@public_channel.save_tags('sensor')
channels = Channel.with_tag('sensor')
channels.count.should == 1
end
end
end

View File

@ -0,0 +1,21 @@
# == Schema Information
#
# Table name: comments
#
# id :integer not null, primary key
# parent_id :integer
# body :text
# flags :integer
# user_id :integer
# ip_address :string(255)
# created_at :datetime
# updated_at :datetime
# channel_id :integer
#
require 'spec_helper'
describe Comment do
end

View File

@ -0,0 +1,17 @@
# == Schema Information
#
# Table name: failedlogins
#
# id :integer not null, primary key
# login :string(255)
# password :string(255)
# ip_address :string(255)
# created_at :datetime
# updated_at :datetime
#
require 'spec_helper'
describe Failedlogin do
end

View File

@ -0,0 +1,18 @@
# == Schema Information
#
# Table name: headers
#
# id :integer not null, primary key
# name :string(255)
# value :string(255)
# created_at :datetime
# updated_at :datetime
# thinghttp_id :integer
#
require 'spec_helper'
describe Header do
end

20
spec/models/pipe_spec.rb Normal file
View File

@ -0,0 +1,20 @@
# == Schema Information
#
# Table name: pipes
#
# id :integer not null, primary key
# name :string(255) not null
# url :string(255) not null
# slug :string(255) not null
# created_at :datetime
# updated_at :datetime
# parse :string(255)
# cache :integer
#
require 'spec_helper'
describe Pipe do
end

134
spec/models/plugin_spec.rb Normal file
View File

@ -0,0 +1,134 @@
# == Schema Information
#
# Table name: plugins
#
# id :integer not null, primary key
# name :string(255)
# user_id :integer
# html :text
# css :text
# js :text
# created_at :datetime
# updated_at :datetime
# private_flag :boolean default(TRUE)
#
require 'spec_helper'
describe Plugin do
before :each do
@user = FactoryGirl.create(:user)
@channel = FactoryGirl.create(:channel, :user => @user)
@window = FactoryGirl.create(:plugin_window, :channel => @channel)
end
it "should be valid" do
plugin = Plugin.new
plugin.should be_valid
end
it "should confirm has_[public\private]_windows" do
plugin = Plugin.new
window = PluginWindow.new
window.private_flag = true
window.channel_id = 1
plugin.windows << window
plugin.has_private_windows(1).should be_true
plugin.has_public_windows(1).should be_false
end
it "new, public plugin should get 2 plugin windows" do
plugin = Plugin.new
plugin.private_flag = false
plugin.public?.should be_true
#Private plugins have one window..
#Public plugins have a private window and a public window
plugin.make_windows @channel.id, "localhost"
plugin.windows.size.should eq(2)
end
it "new, private window should not be showing" do
plugin = Plugin.new
plugin.private_flag = true
plugin.public?.should be_false
#Private plugins have one window..
plugin.make_windows @channel.id, "localhost"
plugin.windows.size.should eq(1)
window = plugin.windows[0]
window.show_flag.should be_false
end
it "should destroy public windows when changing plugin from public to private" do
plugin = Plugin.new
plugin.private_flag = true
plugin.public?.should be_false
#Private plugins have one window..
plugin.make_windows @channel.id, "localhost"
plugin.windows.size.should eq(1)
plugin.private_flag = false
plugin.save
plugin.make_windows @channel.id, "localhost"
plugin.windows.size.should eq(2)
plugin.private_flag = true
plugin.save
plugin.make_windows @channel.id, "localhost"
plugin.windows.size.should eq(1)
end
it "should allow only private_windows to be retrieved" do
plugin = Plugin.new
plugin.private_flag = false
plugin.public?.should be_true
#Private window has private_dashboard_visibility only
plugin.make_windows @channel.id, "localhost"
plugin.windows.size.should eq(2)
plugin.private_dashboard_windows(@channel.id).size.should eq(1)
end
it "should allow only public_windows to be retrieved" do
plugin = Plugin.new
plugin.private_flag = false
plugin.public?.should be_true
#Private window has private_dashboard_visibility only
plugin.make_windows @channel.id, "localhost"
plugin.windows.size.should eq(2)
plugin.public_dashboard_windows(@channel.id).size.should eq(1)
end
it "should cascade delete to Window" do
plugin = Plugin.new
plugin.make_windows @channel.id, "localhost"
window_id = plugin.windows[0].id
plugin.destroy
windows = Window.find_all_by_id(window_id)
windows.size.should eq(0)
end
it "should have windows associated with separate channels" do
channel2 = FactoryGirl.create(:channel, :user => @user)
plugin = Plugin.new
plugin.make_windows @channel.id, "localhost"
plugin.make_windows channel2.id, "localhost"
plugin.windows.size.should eq(2)
plugin.private_dashboard_windows(@channel.id).size.should eq(1)
plugin.private_dashboard_windows(channel2.id).size.should eq(1)
end
end

View File

@ -0,0 +1,54 @@
# == Schema Information
#
# Table name: plugin_window_details
#
# id :integer not null, primary key
# plugin_id :integer
# plugin_window_id :integer
# created_at :datetime
# updated_at :datetime
#
require 'spec_helper'
describe PluginWindowDetail do
before :each do
@channel = FactoryGirl.create(:channel)
@plugin = FactoryGirl.create(:plugin)
end
it "should be valid" do
winDetail = PluginWindowDetail.new
winDetail.should be_valid
end
it "should allow windows plugin association" do
window = Window.new_from @plugin, @channel.id, :private, "localhost"
@plugin.windows << window
@plugin.save
window.should be_valid
window.window_detail.should_not be_nil
end
end
describe PluginWindowDetail do
before :each do
@user = FactoryGirl.create(:user)
@channel = FactoryGirl.create(:channel, :user => @user)
@plugin = FactoryGirl.create(:plugin, :user => @user)
end
it "should differentiate between public plugin_window and private plugin_window" do
window = Window.new_from @plugin, @channel.id, true, "localhost"
@plugin.windows << window
@plugin.save
plugin = PluginWindowDetail.find_all_by_plugin_id(@plugin.id)
plugin.length.should == 1
window = Window.new_from @plugin, @channel.id, false, "localhost"
@plugin.windows << window
@plugin.save
plugin = PluginWindowDetail.find_all_by_plugin_id(@plugin.id)
plugin.length.should == 2
end
end

15
spec/models/tag_spec.rb Normal file
View File

@ -0,0 +1,15 @@
# == Schema Information
#
# Table name: tags
#
# id :integer not null, primary key
# name :string(255)
# created_at :datetime
# updated_at :datetime
#
require 'spec_helper'
describe Tag do
end

View File

@ -0,0 +1,16 @@
# == Schema Information
#
# Table name: taggings
#
# id :integer not null, primary key
# tag_id :integer
# channel_id :integer
# created_at :datetime
# updated_at :datetime
#
require 'spec_helper'
describe Tagging do
end

View File

@ -0,0 +1,22 @@
# == Schema Information
#
# Table name: twitter_accounts
#
# id :integer not null, primary key
# screen_name :string(255)
# user_id :integer
# twitter_id :integer
# token :string(255)
# secret :string(255)
# created_at :datetime
# updated_at :datetime
# api_key :string(17) not null
#
require 'spec_helper'
describe TwitterAccount do
end

View File

@ -0,0 +1,16 @@
# == Schema Information
#
# Table name: watchings
#
# id :integer not null, primary key
# user_id :integer
# channel_id :integer
# created_at :datetime
# updated_at :datetime
#
require 'spec_helper'
describe Watching do
end

View File

@ -0,0 +1,29 @@
# == Schema Information
#
# Table name: windows
#
# id :integer not null, primary key
# channel_id :integer
# position :integer
# created_at :datetime
# updated_at :datetime
# html :text
# col :integer
# title :string(255)
# wtype :string(255)
# name :string(255)
# type :string(255)
# private_flag :boolean default(FALSE)
# show_flag :boolean default(TRUE)
#
require 'spec_helper'
describe Window do
it "should be valid" do
window = Window.new
window.should be_valid
end
end