saucy 0.1.11 → 0.1.12

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.
@@ -46,6 +46,6 @@ class AccountsController < ApplicationController
46
46
  private
47
47
 
48
48
  def current_account
49
- Account.find_by_url!(params[:id])
49
+ Account.find_by_keyword!(params[:id])
50
50
  end
51
51
  end
data/app/models/signup.rb CHANGED
@@ -7,8 +7,8 @@ class Signup
7
7
 
8
8
  FIELDS = {
9
9
  :account => {
10
- :name => :account_name,
11
- :url => :url,
10
+ :name => :account_name,
11
+ :keyword => :keyword,
12
12
  },
13
13
  :user => {
14
14
  :name => :user_name,
@@ -18,7 +18,7 @@ class Signup
18
18
  }
19
19
  }.freeze
20
20
 
21
- attr_accessor :account_name, :url, :user_name, :email, :password,
21
+ attr_accessor :account_name, :keyword, :user_name, :email, :password,
22
22
  :password_confirmation
23
23
 
24
24
  def initialize(attributes = {})
@@ -7,7 +7,7 @@
7
7
  <%= semantic_form_for @account do |form| %>
8
8
  <%= form.inputs do %>
9
9
  <%= form.input :name, :label => "Account name" %>
10
- <%= form.input :url %>
10
+ <%= form.input :keyword %>
11
11
  <% end %>
12
12
 
13
13
  <%= form.buttons do %>
@@ -6,7 +6,7 @@
6
6
  <h5 class="legend">Basic Information</h5>
7
7
  <%= form.inputs do %>
8
8
  <%= form.input :account_name, :label => 'Company Name' %>
9
- <%= form.input :url, :label => 'Account URL', :hint => "http://copycopter.com/accounturl" %>
9
+ <%= form.input :keyword, :hint => "#{root_url}/accounts/<span>accounturl</span>" %>
10
10
  <% end %>
11
11
 
12
12
  <% unless signed_in? -%>
@@ -1,3 +1,4 @@
1
+ <h2>Invite a new User</h2>
1
2
  <%= semantic_form_for [current_account, @invitation] do |form| -%>
2
3
  <%= form.inputs do -%>
3
4
  <%= form.input :email %>
@@ -1,5 +1,5 @@
1
1
  <%= form.inputs do %>
2
2
  <%= form.input :name %>
3
- <%= form.input :url %>
3
+ <%= form.input :keyword %>
4
4
  <%= form.input :users, :as => :check_boxes, :collection => users %>
5
5
  <% end %>
@@ -14,8 +14,8 @@ Factory.define :user do |user|
14
14
  end
15
15
 
16
16
  Factory.define :account do |f|
17
- f.name { Factory.next(:name) }
18
- f.url { Factory.next(:name) }
17
+ f.name { Factory.next(:name) }
18
+ f.keyword { Factory.next(:name) }
19
19
  end
20
20
 
21
21
  Factory.define :membership do |f|
@@ -25,7 +25,7 @@ end
25
25
 
26
26
  Factory.define :signup do |f|
27
27
  f.account_name { Factory.next(:name) }
28
- f.url { Factory.next(:name) }
28
+ f.keyword { Factory.next(:name) }
29
29
  f.user_name { "test user" }
30
30
  f.email { Factory.next :email }
31
31
  f.password { "password" }
@@ -35,7 +35,7 @@ end
35
35
  Factory.define :project do |f|
36
36
  f.association :account
37
37
  f.name { Factory.next(:name) }
38
- f.url { Factory.next(:name) }
38
+ f.keyword { Factory.next(:name) }
39
39
  end
40
40
 
41
41
  Factory.define :permission do |f|
@@ -12,7 +12,7 @@ Feature: Manage Projects
12
12
  When I go to the projects page for the "Test" account
13
13
  And I follow "New Project"
14
14
  And I fill in "Name" with "Project 1"
15
- And I fill in "Url" with "project1"
15
+ And I fill in "Keyword" with "project1"
16
16
  And I press "Create"
17
17
  And I go to the projects page for the "Test" account
18
18
  Then I should see "Project 1" within "ul.projects"
@@ -9,13 +9,13 @@ Feature: user adds a new account
9
9
  And I fill in "Email" with "user@example.com"
10
10
  And I fill in "Password" with "test"
11
11
  And I fill in "Company Name" with "Robots"
12
- And I fill in "Account URL" with "robots"
12
+ And I fill in "Keyword" with "robots"
13
13
  And I press "Sign up"
14
14
  Then I should see "created"
15
15
  But I should not see "Instructions for confirming"
16
16
  When I go to the settings page
17
17
  And I follow "Robots"
18
- Then the "Url" field should contain "robots"
18
+ Then the "Keyword" field should contain "robots"
19
19
 
20
20
  Scenario: sign up for two accounts
21
21
  When I go to the sign up page for the "Free" plan
@@ -24,21 +24,21 @@ Feature: user adds a new account
24
24
  And I fill in "Confirm password" with "password"
25
25
  And I fill in "Your name" with "Robot"
26
26
  And I fill in "Company Name" with "Robots, Inc"
27
- And I fill in "Account URL" with "robots"
27
+ And I fill in "Keyword" with "robots"
28
28
  And I press "Sign up"
29
29
  Then I should see "created"
30
30
  When I go to the settings page
31
31
  And I follow "Robots, Inc"
32
- Then the "Url" field should contain "robots"
32
+ Then the "Keyword" field should contain "robots"
33
33
  When I go to the settings page
34
34
  And I follow "Add new account"
35
35
  And I follow "Free"
36
36
  And I fill in "Company Name" with "Machines"
37
- And I fill in "Account URL" with "machines"
37
+ And I fill in "Keyword" with "machines"
38
38
  And I press "Sign up"
39
39
  Then I should see "created"
40
40
  But I should not see "Instructions for confirming"
41
41
  When I go to the settings page
42
42
  And I follow "Machines"
43
- Then the "Url" field should contain "machines"
43
+ Then the "Keyword" field should contain "machines"
44
44
 
@@ -22,6 +22,6 @@ Feature: Sign up
22
22
  And I fill in "Confirm password" with "password"
23
23
  And I fill in "Your name" with "Robot"
24
24
  And I fill in "Company Name" with "Robots, Inc"
25
- And I fill in "Account URL" with "robotsinc"
25
+ And I fill in "Keyword" with "robotsinc"
26
26
  And I press "Sign up"
27
27
  Then I should see "created"
@@ -13,11 +13,12 @@ class CreateSaucyTables < ActiveRecord::Migration
13
13
  create_table :accounts do |table|
14
14
  table.belongs_to :plan
15
15
  table.string :name
16
- table.string :url
16
+ table.string :keyword
17
17
  table.datetime :created_at
18
18
  table.datetime :updated_at
19
19
  end
20
20
  add_index :accounts, :plan_id
21
+ add_index :accounts, :keyword
21
22
 
22
23
  create_table :invitations do |table|
23
24
  table.string :email
@@ -42,11 +43,12 @@ class CreateSaucyTables < ActiveRecord::Migration
42
43
 
43
44
  create_table :projects do |table|
44
45
  table.string :name
45
- table.string :url
46
+ table.string :keyword
46
47
  table.integer :account_id
47
48
  table.datetime :created_at
48
49
  table.datetime :updated_at
49
50
  end
51
+ add_index :projects, :keyword
50
52
 
51
53
  alter_table :users do |table|
52
54
  table.string :name, :default => ""
data/lib/saucy/account.rb CHANGED
@@ -12,22 +12,19 @@ module Saucy
12
12
 
13
13
  belongs_to :plan
14
14
 
15
- validates_uniqueness_of :name, :url
16
- validates_presence_of :name, :url
15
+ validates_uniqueness_of :name, :keyword
16
+ validates_presence_of :name, :keyword
17
17
 
18
- attr_accessible :name, :url
18
+ attr_accessible :name, :keyword
19
19
 
20
- validates_format_of :url,
21
- :with => %r{^[a-z0-9]+$},
22
- :message => "must be only lower case letters."
23
- validates_exclusion_of :url,
24
- :in => %w[app admin blog dev ftp mail pop pop3 imap smtp staging stats status www],
25
- :message => 'is reserved.'
20
+ validates_format_of :keyword,
21
+ :with => %r{^[a-z0-9]+$},
22
+ :message => "must be only lower case letters."
26
23
  end
27
24
 
28
25
  module InstanceMethods
29
26
  def to_param
30
- url
27
+ keyword
31
28
  end
32
29
 
33
30
  def has_member?(user)
@@ -11,11 +11,11 @@ module Saucy
11
11
  protected
12
12
 
13
13
  def current_account
14
- ::Account.find_by_url!(params[:account_id])
14
+ ::Account.find_by_keyword!(params[:account_id])
15
15
  end
16
16
 
17
17
  def current_project
18
- ::Project.find_by_url!(params[:project_id])
18
+ ::Project.find_by_keyword!(params[:project_id])
19
19
  end
20
20
 
21
21
  def authorize_admin
data/lib/saucy/project.rb CHANGED
@@ -7,11 +7,11 @@ module Saucy
7
7
  has_many :permissions, :dependent => :destroy
8
8
  has_many :users, :through => :permissions
9
9
 
10
- validates_presence_of :account_id, :url, :name
10
+ validates_presence_of :account_id, :keyword, :name
11
11
 
12
- validates_uniqueness_of :url, :scope => :account_id
12
+ validates_uniqueness_of :keyword, :scope => :account_id
13
13
 
14
- validates_format_of :url,
14
+ validates_format_of :keyword,
15
15
  :with => %r{^[a-z0-9]+$},
16
16
  :message => "must be only lower case letters."
17
17
 
@@ -37,7 +37,7 @@ module Saucy
37
37
 
38
38
  module InstanceMethods
39
39
  def to_param
40
- url
40
+ keyword
41
41
  end
42
42
 
43
43
  def has_member?(user)
@@ -23,11 +23,11 @@ module Saucy
23
23
  end
24
24
 
25
25
  def edit
26
- @project = ::Project.find_by_url!(params[:id])
26
+ @project = ::Project.find_by_keyword!(params[:id])
27
27
  end
28
28
 
29
29
  def update
30
- @project = ::Project.find_by_url!(params[:id])
30
+ @project = ::Project.find_by_keyword!(params[:id])
31
31
  if @project.update_attributes params[:project]
32
32
  flash[:success] = 'Project was updated.'
33
33
  redirect_to account_projects_url(current_account)
@@ -37,7 +37,7 @@ module Saucy
37
37
  end
38
38
 
39
39
  def destroy
40
- @project = ::Project.find_by_url!(params[:id])
40
+ @project = ::Project.find_by_keyword!(params[:id])
41
41
  @project.destroy
42
42
  flash[:success] = "Project has been deleted"
43
43
  redirect_to account_projects_url(@project.account)
@@ -5,7 +5,7 @@ describe ApplicationController do
5
5
  describe "with a valid account id in the params" do
6
6
  before do
7
7
  @account = Factory(:account)
8
- @controller.stubs(:params).returns(:account_id => @account.url)
8
+ @controller.stubs(:params).returns(:account_id => @account.to_param)
9
9
  end
10
10
 
11
11
  it "should return the corresponding account from current_account" do
@@ -27,7 +27,7 @@ describe InvitationsController, "new", :as => :account_admin do
27
27
  let(:projects) { ['one', 'two'] }
28
28
 
29
29
  before do
30
- Account.stubs(:find_by_url! => account)
30
+ Account.stubs(:find_by_keyword! => account)
31
31
  account.stubs(:projects_by_name => projects)
32
32
  Invitation.stubs(:new => invitation)
33
33
  get :new, :account_id => account.to_param
@@ -81,7 +81,7 @@ describe InvitationsController, "invalid create", :as => :account_admin do
81
81
  before do
82
82
  Invitation.stubs(:new => invitation)
83
83
  invitation.stubs(:save => false)
84
- Account.stubs(:find_by_url! => account)
84
+ Account.stubs(:find_by_keyword! => account)
85
85
  account.stubs(:projects_by_name => projects)
86
86
  post :create, :account_id => account.to_param, :invitation => {}
87
87
  end
@@ -26,7 +26,7 @@ describe MembershipsController, "index", :as => :account_admin do
26
26
  let(:memberships) { [Factory.stub(:membership), Factory.stub(:membership)] }
27
27
 
28
28
  before do
29
- Account.stubs(:find_by_url! => account)
29
+ Account.stubs(:find_by_keyword! => account)
30
30
  account.stubs(:memberships_by_name => memberships)
31
31
  get :index, :account_id => account.to_param
32
32
  end
@@ -91,7 +91,7 @@ describe ProjectsController, "index", :as => :account_admin do
91
91
  let(:projects) { ['one', 'two'] }
92
92
 
93
93
  before do
94
- Account.stubs(:find_by_url! => account)
94
+ Account.stubs(:find_by_keyword! => account)
95
95
  account.stubs(:projects => projects)
96
96
  get :index, :account_id => account.to_param
97
97
  end
@@ -8,30 +8,25 @@ describe Account do
8
8
  it { should have_many(:projects) }
9
9
 
10
10
  it { should validate_uniqueness_of(:name) }
11
- it { should validate_uniqueness_of(:url) }
11
+ it { should validate_uniqueness_of(:keyword) }
12
12
  it { should validate_presence_of( :name) }
13
- it { should validate_presence_of(:url) }
13
+ it { should validate_presence_of(:keyword) }
14
14
 
15
15
  it { should_not allow_mass_assignment_of(:id) }
16
16
  it { should_not allow_mass_assignment_of(:updated_at) }
17
17
  it { should_not allow_mass_assignment_of(:created_at) }
18
- it { should allow_mass_assignment_of(:url) }
18
+ it { should allow_mass_assignment_of(:keyword) }
19
19
 
20
20
  [nil, "", "a b", "a.b", "a%b"].each do |value|
21
- it { should_not allow_value(value).for(:url).with_message(/letters/i) }
22
- end
23
-
24
- ["admin", "blog", "dev", "ftp", "mail", "pop", "pop3", "imap", "smtp",
25
- "staging", "stats", "status","www"].each do |value|
26
- it { should_not allow_value(value).for(:url).with_message(/reserved/i) }
21
+ it { should_not allow_value(value).for(:keyword).with_message(/letters/i) }
27
22
  end
28
23
 
29
24
  ["foo", "f00", "37signals"].each do |value|
30
- it { should allow_value(value).for(:url) }
25
+ it { should allow_value(value).for(:keyword) }
31
26
  end
32
27
 
33
- it "should give its url for to_param" do
34
- subject.to_param.should == subject.url
28
+ it "should give its keyword for to_param" do
29
+ subject.to_param.should == subject.keyword
35
30
  end
36
31
 
37
32
  it "finds admin users" do
@@ -5,7 +5,7 @@ describe Project do
5
5
  it { should validate_presence_of(:account_id) }
6
6
  it { should have_many(:permissions) }
7
7
  it { should have_many(:users).through(:permissions) }
8
- it { should validate_presence_of(:url) }
8
+ it { should validate_presence_of(:keyword) }
9
9
  it { should validate_presence_of(:name) }
10
10
 
11
11
  it "finds projects visible to a user" do
@@ -31,22 +31,22 @@ describe Project do
31
31
  Project.by_name.map(&:name).should == %w(abc def ghi)
32
32
  end
33
33
 
34
- it "should give its url for to_param" do
34
+ it "should give its keyword for to_param" do
35
35
  project = Factory(:project)
36
- project.to_param.should == project.url
36
+ project.to_param.should == project.keyword
37
37
  end
38
38
  end
39
39
 
40
- describe Project, "url uniqueness" do
40
+ describe Project, "keyword uniqueness" do
41
41
  let(:project) { Factory(:project) }
42
42
  subject do
43
43
  Factory.build(:project, :account => project.account)
44
44
  end
45
45
 
46
- it "validates uniqueness of it's url" do
47
- subject.url = project.url
46
+ it "validates uniqueness of it's keyword" do
47
+ subject.keyword = project.keyword
48
48
  subject.save
49
- subject.errors[:url].should include("has already been taken")
49
+ subject.errors[:keyword].should include("has already been taken")
50
50
  end
51
51
  end
52
52
 
@@ -10,11 +10,11 @@ describe Signup do
10
10
  end
11
11
 
12
12
  describe Signup, "with attributes in the constructor" do
13
- subject { Signup.new(:user_name => 'Joe', :account_name => 'blokes', :url => 'blk') }
13
+ subject { Signup.new(:user_name => 'Joe', :account_name => 'blokes', :keyword => 'blk') }
14
14
  it "assigns attributes" do
15
15
  subject.user_name.should == 'Joe'
16
16
  subject.account_name.should == 'blokes'
17
- subject.url.should == 'blk'
17
+ subject.keyword.should == 'blk'
18
18
  end
19
19
  end
20
20
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saucy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 11
10
- version: 0.1.11
9
+ - 12
10
+ version: 0.1.12
11
11
  platform: ruby
12
12
  authors:
13
13
  - thoughtbot, inc.